Skip to content

Why action type is connected to specific event type? #1649

Answered by davidkpiano
baeharam asked this question in Q&A
Discussion options

You must be logged in to vote

My question is that why action needs specific event type? Action shouldn't be connected to only one event. It can be used at several events like 1:N connection.

The assign<TContext, TEvent>(...) action creator currently needs the specific event type because you might use the event in the assignment itself, and of course, you can't just assume any event when it can only be a specific type of event for the transition

However, for your assign call, you're not even using event, so perhaps there are ways to improve this on the XState side, but for now, assign<SomeContext, any>(...) suffices.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by baeharam
Comment options

You must be logged in to vote
2 replies
@davidkpiano
Comment options

@baeharam
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants