Minor Changes
-
#4467
3c71e537d
Thanks @Andarist! - Thestate.configuration
property has been renamed tostate._nodes
.- state.configuration + state._nodes
-
#4467
3c71e537d
Thanks @Andarist! - Thestate.meta
getter has been replaced withstate.getMeta()
methods:- state.meta + state.getMeta()
-
#4353
a3a11c84e
Thanks @davidkpiano! - You can now use thesetup({ ... }).createMachine({ ... })
function to setup implementations foractors
,actions
,guards
, anddelays
that will be used in the created machine:import { setup, createMachine } from 'xstate'; const fetchUser = fromPromise(async ({ input }) => { const response = await fetch(`/user/${input.id}`); const user = await response.json(); return user; }); const machine = setup({ actors: { fetchUser }, actions: { clearUser: assign({ user: undefined }) }, guards: { isUserAdmin: (_, params) => params.user.role === 'admin' } }).createMachine({ // ... invoke: { // Strongly typed! src: 'fetchUser', input: ({ context }) => ({ id: context.userId }), onDone: { guard: { type: 'isUserAdmin', params: ({ context }) => ({ user: context.user }) }, target: 'success', actions: assign({ user: ({ event }) => event.output }) }, onError: { target: 'failure', actions: 'clearUser' } } });