Last active
March 11, 2020 18:30
-
-
Save hosmelq/dd2aeeb5d477e2049334cd66f9201e40 to your computer and use it in GitHub Desktop.
Revisions
-
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -136,11 +136,7 @@ Machine( onDone: `done`, onError: [ { target: `done` } ] } -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -136,7 +136,11 @@ Machine( onDone: `done`, onError: [ { target: `done`, actions: (ctx, event) => { console.log(`ctx: `, ctx) console.log(`event: `, event) } } ] } -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -136,11 +136,7 @@ Machine( onDone: `done`, onError: [ { target: `done` } ] } -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ Machine( initial: `initializing`, context: { fetchKey: 1, online: false, offer: { id: null, receivedAt: null -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const ORDER_STATE = { IN_PROGRESS: `IN_PROGRESS`, WAITING_COURIER: `WAITING_COURIER` } const CURRENT_ORDER_TYPE = `DELIVERY` const ORDER_TYPE = { DELIVERY: `DELIVERY`, HIRED: `HIRED` @@ -22,7 +22,7 @@ Machine( initial: `initializing`, context: { fetchKey: 1, online: true, offer: { id: null, receivedAt: null -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const ORDER_STATE = { IN_PROGRESS: `IN_PROGRESS`, WAITING_COURIER: `WAITING_COURIER` } const CURRENT_ORDER_TYPE = `HIRED` const ORDER_TYPE = { DELIVERY: `DELIVERY`, HIRED: `HIRED` @@ -105,15 +105,14 @@ Machine( }, { cond: `isHiredOrder`, actions: `incrementFetchKey`, target: `waiting` } ], onError: `waiting` } }, offer: { onDone: `waiting`, initial: `waiting`, -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 3 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ Machine( initial: `initializing`, context: { fetchKey: 1, online: false, offer: { id: null, receivedAt: null @@ -182,7 +182,7 @@ Machine( setOnline: assign({ online: () => true, }), setOfferId: assign({ offer: () => ({ acceptedAt: new Date(), @@ -225,10 +225,7 @@ Machine( isAssigned: (ctx, event) => ORDER_STATE.IN_PROGRESS === CURRENT_ORDER_STATE, isDeliveryOrder: (ctx, event) => ORDER_TYPE.DELIVERY === CURRENT_ORDER_TYPE, isHiredOrder: (ctx, event) => ORDER_TYPE.HIRED === CURRENT_ORDER_TYPE, doesNotHaveEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return false } -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 1 addition and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -116,25 +116,8 @@ Machine( offer: { onDone: `waiting`, initial: `waiting`, states: { waiting: { entry: `vibrate`, exit: `cancelVibration`, -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function buildVibrationPattern(seconds) { } const DEFAULT_WAIT_TIME = 30000 const CURRENT_ORDER_STATE = `WAITING_COURIER` const ORDER_STATE = { IN_PROGRESS: `IN_PROGRESS`, WAITING_COURIER: `WAITING_COURIER` -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -244,10 +244,10 @@ Machine( isHiredOrder: (ctx, event) => ORDER_TYPE.HIRED === CURRENT_ORDER_TYPE, hasEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return true }, doesNotHaveEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return false } } } -
hosmelq revised this gist
Mar 11, 2020 . No changes.There are no files selected for viewing
-
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -95,6 +95,10 @@ Machine( actions: `incrementFetchKey`, target: `waiting` }, { cond: `doesNotHaveEnoughTimeToAcceptOrder`, target: `waiting` }, { cond: `isDeliveryOrder`, target: `offer` @@ -240,9 +244,11 @@ Machine( isHiredOrder: (ctx, event) => ORDER_TYPE.HIRED === CURRENT_ORDER_TYPE, hasEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return Math.floor(receivedAt + DEFAULT_WAIT_TIME - Date.now()) > 2500 }, doesNotHaveEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return Math.floor(receivedAt + DEFAULT_WAIT_TIME - Date.now()) < 2500 } } } ) -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -212,7 +212,7 @@ Machine( }), incrementFetchKey: assign({ fetchKey: (ctx) => ctx.fetchKey + 1, }), vibrate: () => { -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -93,7 +93,7 @@ Machine( { cond: `isAssigned`, actions: `incrementFetchKey`, target: `waiting` }, { cond: `isDeliveryOrder`, @@ -212,9 +212,7 @@ Machine( }), incrementFetchKey: assign({ fetchKey: (ctx) => ++ctx.fetchKey, }), vibrate: () => { -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,6 @@ function buildVibrationPattern(seconds) { .reduce(prev => [...prev, 0, 1000, 500], []) } const DEFAULT_WAIT_TIME = 30000 const CURRENT_ORDER_STATE = `IN_PROGRESS` const ORDER_STATE = { @@ -23,7 +22,7 @@ Machine( initial: `initializing`, context: { fetchKey: 1, online: true, offer: { id: null, receivedAt: null -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ function buildVibrationPattern(seconds) { .reduce(prev => [...prev, 0, 1000, 500], []) } const ONLINE = true const DEFAULT_WAIT_TIME = 30000 const CURRENT_ORDER_STATE = `IN_PROGRESS` const ORDER_STATE = { @@ -22,7 +23,7 @@ Machine( initial: `initializing`, context: { fetchKey: 1, online: ONLINE, offer: { id: null, receivedAt: null -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 13 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -196,13 +196,6 @@ Machine( online: () => true, }), setOfferId: assign({ offer: () => ({ acceptedAt: new Date(), @@ -217,6 +210,19 @@ Machine( receivedAt: null, }), }), incrementFetchKey: assign({ fetchKey: (ctx) => ({ fetchKey: ++ctx.fetchKey }), }), vibrate: () => { console.log(`vibrate`) }, cancelVibration: () => { console.log(`cancelVibration`) }, }, delays: { ORDER_DELAY: ctx => { -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 16 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,12 @@ function buildVibrationPattern(seconds) { } const DEFAULT_WAIT_TIME = 30000 const CURRENT_ORDER_STATE = `IN_PROGRESS` const ORDER_STATE = { IN_PROGRESS: `IN_PROGRESS`, WAITING_COURIER: `WAITING_COURIER` } const CURRENT_ORDER_TYPE = `DELIVERY` const ORDER_TYPE = { DELIVERY: `DELIVERY`, HIRED: `HIRED` @@ -15,6 +21,7 @@ Machine( id: `courier-state-and-jobs`, initial: `initializing`, context: { fetchKey: 1, online: false, offer: { id: null, @@ -74,13 +81,6 @@ Machine( ORDER_RECEIVED: { actions: `setOffer`, target: `fetchingOrder` } } }, @@ -90,6 +90,11 @@ Machine( id: `fetchOrder`, src: `fetchOrder`, onDone: [ { cond: `isAssigned`, actions: `incrementFetchKey`, target: `offer` }, { cond: `isDeliveryOrder`, target: `offer` @@ -226,10 +231,12 @@ Machine( isOffline: ctx => !ctx.online, isOnline: ctx => ctx.online, isAssigned: (ctx, event) => ORDER_STATE.IN_PROGRESS === CURRENT_ORDER_STATE, isDeliveryOrder: (ctx, event) => ORDER_TYPE.DELIVERY === CURRENT_ORDER_TYPE, isHiredOrder: (ctx, event) => ORDER_TYPE.HIRED === CURRENT_ORDER_TYPE, hasEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return true return Math.floor(receivedAt + DEFAULT_WAIT_TIME - Date.now()) > 2500 }, } -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ Machine( id: `courier-state-and-jobs`, initial: `initializing`, context: { online: false, offer: { id: null, receivedAt: null @@ -71,7 +71,10 @@ Machine( states: { waiting: { on: { ORDER_RECEIVED: { actions: `setOffer`, target: `fetchingOrder` }, ORDER_ASSIGNED: { actions: `reloadOrderList` }, -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,10 @@ function buildVibrationPattern(seconds) { } const DEFAULT_WAIT_TIME = 30000 const ORDER_TYPE = { DELIVERY: `DELIVERY`, HIRED: `HIRED` } Machine( { @@ -218,6 +222,10 @@ Machine( guards: { isOffline: ctx => !ctx.online, isOnline: ctx => ctx.online, isDeliveryOrder: (ctx, event) => ORDER_TYPE.DELIVERY === event.type, isHiredOrder: (ctx, event) => ORDER_TYPE.HIRED === event.type, hasEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return Math.floor(receivedAt + DEFAULT_WAIT_TIME - Date.now()) > 2500 }, -
hosmelq revised this gist
Mar 11, 2020 . 1 changed file with 24 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,6 @@ Machine( context: { online: true, offer: { id: null, receivedAt: null } @@ -68,7 +67,7 @@ Machine( states: { waiting: { on: { ORDER_RECEIVED: `fetchingOrder`, ORDER_ASSIGNED: { actions: `reloadOrderList` }, @@ -79,6 +78,26 @@ Machine( } }, fetchingOrder: { invoke: { id: `fetchOrder`, src: `fetchOrder`, onDone: [ { cond: `isDeliveryOrder`, target: `offer` }, { cond: `isHiredOrder`, target: `assignment` } ], onError: `waiting` } }, assignment: {}, offer: { onDone: `waiting`, initial: `validating`, @@ -119,6 +138,7 @@ Machine( onDone: `done`, onError: [ { target: `done`, actions: (ctx, event) => { console.log(`ctx: `, ctx) console.log(`event: `, event) @@ -135,11 +155,11 @@ Machine( onDone: `done`, onError: [ { target: `done`, actions: (ctx, event) => { console.log(`ctx: `, ctx) console.log(`event: `, event) } } ] } -
hosmelq revised this gist
Mar 6, 2020 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,11 +68,11 @@ Machine( states: { waiting: { on: { '*': `offer`, ORDER_ASSIGNED: { actions: `reloadOrderList` }, ORDER_OFFER_RECEIVED: { actions: `setOffer`, target: `offer` } @@ -201,7 +201,6 @@ Machine( hasEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return Math.floor(receivedAt + DEFAULT_WAIT_TIME - Date.now()) > 2500 }, } } ) -
hosmelq revised this gist
Mar 6, 2020 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,6 +68,9 @@ Machine( states: { waiting: { on: { ORDER_ASSIGNED: { actions: `reloadOrderList` }, ORDER_OFFER_RECEIVED: { cond: `isValidOffer`, actions: `setOffer`, -
hosmelq revised this gist
Mar 6, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,7 +68,7 @@ Machine( states: { waiting: { on: { ORDER_OFFER_RECEIVED: { cond: `isValidOffer`, actions: `setOffer`, target: `offer` -
hosmelq revised this gist
Mar 6, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -195,8 +195,8 @@ Machine( guards: { isOffline: ctx => !ctx.online, isOnline: ctx => ctx.online, hasEnoughTimeToAcceptOrder: ({offer: {receivedAt}}) => { return Math.floor(receivedAt + DEFAULT_WAIT_TIME - Date.now()) > 2500 }, isValidOffer: () => true, } -
hosmelq revised this gist
Mar 6, 2020 . 1 changed file with 14 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -84,7 +84,15 @@ Machine( invoke: { id: `validateOrder`, src: `validateOrder`, onDone: [ { cond: `hasEnoughTimeToAcceptOrder`, target: `waiting` }, { target: `done` } ], onError: `done` } }, @@ -127,7 +135,8 @@ Machine( actions: (ctx, event) => { console.log(`ctx: `, ctx) console.log(`event: `, event) }, target: `done` } ] } @@ -186,6 +195,9 @@ Machine( guards: { isOffline: ctx => !ctx.online, isOnline: ctx => ctx.online, hasEnoughTimeToAcceptOrder: () => { return true }, isValidOffer: () => true, } } -
hosmelq revised this gist
Mar 6, 2020 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,8 +4,7 @@ function buildVibrationPattern(seconds) { .reduce(prev => [...prev, 0, 1000, 500], []) } const DEFAULT_WAIT_TIME = 30000 Machine( { @@ -178,10 +177,10 @@ Machine( delays: { ORDER_DELAY: ctx => { if (!ctx.time) { return DEFAULT_WAIT_TIME } return Math.floor(ctx.time + DEFAULT_WAIT_TIME - Date.now()) }, }, guards: { -
hosmelq revised this gist
Mar 6, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ Machine( id: `courier-state-and-jobs`, initial: `initializing`, context: { online: true, offer: { acceptedAt: null, id: null, @@ -187,6 +187,7 @@ Machine( guards: { isOffline: ctx => !ctx.online, isOnline: ctx => ctx.online, isValidOffer: () => true, } } ) -
hosmelq revised this gist
Mar 6, 2020 . 1 changed file with 16 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ Machine( id: `courier-state-and-jobs`, initial: `initializing`, context: { online: false, offer: { acceptedAt: null, id: null, @@ -70,7 +70,8 @@ Machine( waiting: { on: { OFFER_RECEIVED: { cond: `isValidOffer`, actions: `setOffer`, target: `offer` } } @@ -84,11 +85,11 @@ Machine( invoke: { id: `validateOrder`, src: `validateOrder`, onDone: `waiting`, onError: `done` } }, waiting: { entry: `vibrate`, exit: `cancelVibration`, @@ -121,11 +122,20 @@ Machine( invoke: { id: `rejectOrder`, src: `rejectOrder`, onDone: `done`, onError: [ { actions: (ctx, event) => { console.log(`ctx: `, ctx) console.log(`event: `, event) } } ] } }, done: { entry: `resetOffer`, type: `final` } } -
hosmelq revised this gist
Mar 6, 2020 . No changes.There are no files selected for viewing
NewerOlder