Xstate: Add support for actions with parameters

Created on 2 Dec 2017  路  4Comments  路  Source: davidkpiano/xstate

Most helpful comment

I see, I must have missed that in the readme examples, perhaps having standalone docs would be useful also? Closing.

All 4 comments

Can you expand on what you mean by this?

See https://en.wikipedia.org/wiki/UML_state_machine#Events

An event can have associated parameters, allowing the event instance to convey not only the occurrence of some interesting incident but also quantitative information regarding that occurrence. For example, the Keystroke event generated by pressing a key on a computer keyboard has associated parameters that convey the character scan code as well as the status of the Shift, Ctrl, and Alt keys.

The API is already set up to handle actions with payload/parameters:

machine.transition('green', {
  type: 'TIMER', // the action is determined on the object's `type` prop
  timestamp: Date.now()
});

When I add guard functions, they will be able to make use of action parameters.

I see, I must have missed that in the readme examples, perhaps having standalone docs would be useful also? Closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

suku-h picture suku-h  路  3Comments

mattiamanzati picture mattiamanzati  路  3Comments

laurentpierson picture laurentpierson  路  3Comments

bradwoods picture bradwoods  路  3Comments

greggman picture greggman  路  3Comments