The goal of this task is to add context type to states, so sending an event would require providing the given context shape. The context will be available on event/state updates and state objects.
The challenge is to make it fully type-safe, so passing a wrong context shape would be impossible.
Since multiple transitions can be triggered by the same name event, specifying the destination state (profile in submit() -> profile) for an event would be required for the types to know which shape to expect.
It is possible to omit the destination in case of unambiguous transitions, but it will create an inconsistent API, so I'm 100% confident it's a good idea.
The goal of this task is to add context type to states, so sending an event would require providing the given context shape. The context will be available on event/state updates and state objects.
The challenge is to make it fully type-safe, so passing a wrong context shape would be impossible.
Currently, the state looks like this:
Since multiple transitions can be triggered by the same name event, specifying the destination state (
profile
insubmit() -> profile
) for an event would be required for the types to know which shape to expect.It is possible to omit the destination in case of unambiguous transitions, but it will create an inconsistent API, so I'm 100% confident it's a good idea.