Feature request
Be able to call assign actions using the ActionObject notation, it's also needed to implement <param> and <content> which would be placed into the event (per the SCXML spec).
Example:
onEntry: { type: 'myAction', foo: 'bar' }
// ...
actions: {
myAction: (ctx, e) => {
e.foo === 'bar'; // true
}
}
Anything passed into the action object will be merged with the event object.
Clarification with this after reading the spec: the extra fields passed into the action object will be merged with the resolved action object, not with the event:
onEntry: { type: 'myAction', foo: 'bar' }
// ...
actions: {
myAction: (ctx, e) => {
e.foo === undefined;
}
}
But when that action is returned as part of the State, it is returned as:
{
type: 'myAction',
foo: 'bar',
exec: (ctx, e) => { e.foo === undefined; }
}
Which makes me think that we should pass the action as a 3rd argument to the action?
Which makes me think that we should pass the action as a 3rd argument to the action?
Yes, I think it is a good solution.
Added in the 3rd argument in the actionMeta property as of version 4.4. Docs: https://xstate.js.org/docs/guides/actions.html#declarative-actions
Most helpful comment
Added in the 3rd argument in the
actionMetaproperty as of version 4.4. Docs: https://xstate.js.org/docs/guides/actions.html#declarative-actions