What is a preferable way to handle async side affects? #1689
-
Hi! Can you tell me what variant is the right one or preferable one?
or
The first variant listen to The second variant also listens to So, my main question is "Is it okey to trigger promises as actions or is it always better to put them in a separate state with corresponding service? Or maybe it's preferable to always put promises into state services to make them canceled on machine exit?" P.S. This question is inspired by this comment https://dev.to/codingdive/comment/o1dk in The most elegant debounce code you'll ever write featuring XState article |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I usually go for making a service for such things (so the first variant). Cleanup of stopped machines is nice - like you have mentioned. |
Beta Was this translation helpful? Give feedback.
I usually go for making a service for such things (so the first variant). Cleanup of stopped machines is nice - like you have mentioned.