xstate-viz icon indicating copy to clipboard operation
xstate-viz copied to clipboard

Refactor notification events to use notifModel

Open mattpocock opened this issue 4 years ago • 0 comments

send(
  notifModel.events.BROADCAST(
    'An error occurred when saving.',
    'error',
  ),
  {
    to: (ctx) => {
      return ctx.notifRef!;
    },
  },
),

This is the new preferred pattern. The old pattern is:

send(
  (_, e: any) => ({
    type: 'BROADCAST',
    status: 'error',
    message: e.data.toString(),
  }),
  { to: (ctx: any) => ctx.notifRef },
)

mattpocock avatar Jul 26 '21 10:07 mattpocock