Function mapStatesFromDefinition

  • Most users will prefer to use mapStates. Only use mapStatesFromDefinition if you already have a StateNodeDefinition.

    See

    MapStatesMapper.

    Returns

    The new StateNodeConfig resulting from applying mapper to each state.

    Type Parameters

    • TContext

    • TStateSchema extends StateSchema<any, TStateSchema>

    • TEvent extends EventObject

    Parameters

    • machineOptions: MachineOptions<TContext, TEvent, BaseActionObject, ServiceMap, TypegenDisabled>

      MachineOptions for the definition.

    • definition: StateNodeDefinition<TContext, TStateSchema, TEvent>

      StateNodeDefinition to map over.

    • mapper: MapStatesMapper<TContext, TStateSchema, TEvent>

      Function that maps the existing node and a state path to a possibly-updated new state.

      Generally, mapper should return a modified copy of the provided state. E.g. with (state) => ({ ...state, modifications: "here" }) You should likely have lots of ...s and concats to ensure that you are preserving the parts of the source state that you aren't direclty modifying.

    Returns StateNodeConfig<TContext, TStateSchema, TEvent, BaseActionObject>

Generated using TypeDoc