Skip to content

Serial resolver 🔗 ​

Serial resolver is used to gracefully validate against supersonic supported platforms until it is able to resolve a valid serial.

The serial resolver exports a machine that is intended to be used as the child of another machine. This is done by invoking the machine and then transitioning to the relevant states based on it's emitted events.

Usage ​

js
import { createMachine } from 'xstate';
import { serialMachine } from '@fingermarkglobal/serial.resolver';

const restaurantMachine = createMachine({
  id: 'parent-machine',
  initial: 'serial',
  context: {
    //...
  },
  states: {
    serial: {
      invoke: {
        id: 'serial-machine',
        src: serialMachine,
      },
      on: {
        SERIAL_MACHINE_FAILURE: {
          target: 'failure',
        },
        SERIAL_MACHINE_SUCCESS: {
          target: 'success',
        },
      },
    },
    failure: {
      //...
    },
    success: {
      //...
    },
  },
});

Context

Note this machine makes use of the data attribute which allows us to invoke child machines with exiting context.