SHARE
TWEET

Untitled

a guest Oct 17th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Available variables:
  2.   // - Machine
  3.   // - interpret
  4.   // - assign
  5.   // - send
  6.   // - sendParent
  7.   // - spawn
  8.   // - raise
  9.   // - actions
  10.   // - XState (all XState exports)
  11.  
  12.   const dismissReasonMachine = Machine({
  13.     id: 'dismissReasonMachine',
  14.     initial: 'load',
  15.     context: {
  16.       actions: [],
  17.       reason: undefined,
  18.       action: undefined,
  19.     },
  20.     states: {
  21.       load: {
  22.         invoke: {
  23.           id: 'onLoad',
  24.           src: 'onLoad',
  25.           onDone: [
  26.             {
  27.               cond: 'hasActions',
  28.               target: 'input',
  29.               actions: ['setActions'],
  30.             },
  31.             {
  32.               target: 'error.emptyActions'
  33.             }
  34.           ],
  35.           onError: 'error.serverError',
  36.         },
  37.         on: {
  38.           CANCEL: 'close',
  39.         },
  40.       },
  41.       input: {
  42.         on: {
  43.           SELECT_ACTION: {
  44.             actions: ['setAction'],
  45.           },
  46.           ENTER_REASON: {
  47.             actions: ['setReason']
  48.           },
  49.           CANCEL: 'close',
  50.           SUBMIT: 'save',
  51.         }
  52.       },
  53.       save: {
  54.         invoke: {
  55.           id: 'onSave',
  56.           src: 'onSave',
  57.           onDone: 'success',
  58.           onError: 'error.saveFailed'
  59.         },
  60.       },
  61.       success: {
  62.         on: {
  63.           TIMER: 'close',
  64.         },
  65.       },
  66.       error: {
  67.         states: {
  68.           emptyActions: {},
  69.           serverError: {},
  70.           saveFailed: {},
  71.         }
  72.       },
  73.       close: {
  74.         type: 'final',
  75.       }
  76.     }
  77.   });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top