Trying to find a nice way to declare actions #3812
Replies: 1 comment
-
Out of curiosity - as we are reevaluating some behavior - why this is expected? An argument can be made that if you restore a configuration then those actions were already executed so why would you like to execute them again?
This works if you want to declare your functions outside of the machine. It allows your functions to be less coupled to XState (as you might map the context/event/etc to some other things and use those as arguments). |
Beta Was this translation helpful? Give feedback.
-
When actions are declared as property of machine configuration, they will be executed when the machine will be restored from persisted state as expected
but in above case we can end up with a lot of lines of code in one single file.
As making current state being possible to store for example in local storage means transform the current state into JSON object, obviously a reference to variables will be gone, so in below case after restoring state machine action
activate
won't be executed.It can be solved by using machine configuration actions properties as proxies to accurate functions
but I'm not sure if this solution is well enough.
Do you have any suggestions on that?
Beta Was this translation helpful? Give feedback.
All reactions