Debounce Machine: Function in Context #14
Replies: 2 comments 1 reply
-
Yea, this sounds like the most probable cause of the problem. Functions should not be sent as part of the events payload to avoid this kind of problems. |
Beta Was this translation helpful? Give feedback.
-
Regarding Mateusz answer there is probably a more idiomatic way to model this Statechart, or is there already an accepted generic Debounce Statechart? Two ideas that quickly came to my mind:
And both solutions behave differently, because the action can't be specified dynamically! We might have to think about another solution or accept this as it is... For reference: a quick online search led me to @CodingDive's post: https://dev.to/codingdive/the-most-elegant-debounce-code-you-ll-ever-write-featuring-xstate-3hn0 |
Beta Was this translation helpful? Give feedback.
-
This relates to my comment: #6 (comment)
I just wanted to open an issue in @xstate/inspect for not correctly showing the assigned function in the context when I realized that maybe something is not used correctly. Taking a look at the xstate docs I remembered the following line:
If we take a look at JSON.stringify(...) @ MDN it is clearly stated that:
Maybe this is the reason the XState Inspector does not show functions in the context object? Can @davidkpiano or @Andarist confirm that and maybe even suggest the correct way to do that? Otherwise I would open an issue over at davidkpiano/xstate for discussing this.
Reproduction
The following entry actions:
lead to:
Reproducible examples are listed here:
Beta Was this translation helpful? Give feedback.
All reactions