// Available variables: // - Machine // - interpret // - assign // - send // - sendParent // - spawn // - raise // - actions // - XState (all XState exports) const transportMachine = Machine({ id: 'transport', initial: 'empty', context: { retries: 0 }, states: { empty: { on: { CREATE: 'creating' } }, creating: { on: { RESOLVE: 'success', REJECT: 'failure' } }, success: { type: 'final' }, failure: { on: { RETRY: { target: 'creating', actions: assign({ retries: (ctx, event) => ctx.retries +1 }) } } } } }); // const fetchMachine = Machine({ // id: 'fetch', // initial: 'idle', // context: { // retries: 0 // }, // states: { // idle: { // on: { // FETCH: 'loading' // } // }, // loading: { // on: { // RESOLVE: 'success', // REJECT: 'failure' // } // }, // success: { // type: 'final' // }, // failure: { // on: { // RETRY: { // target: 'loading', // actions: assign({ // retries: (context, event) => context.retries + 1 // }) // } // } // } // } // });