Additional data can be used when getting the state for a transition#7
Additional data can be used when getting the state for a transition#7robinvdvleuten wants to merge 1 commit intowinzou:masterfrom robinvdvleuten:master
Conversation
|
Hi, Sorry for not having reviewedd this earlier, I totally missed it. Unfortunately this is quite a big BC break so I can't merge it like this. Thanks |
|
I think adding this feature (with more test and a documentation) will make this lib way better than yohang/Finite. winzou/state-machine can handle multiple graph with multiple state in a single object, yohang/Finite can't. If you want I am available to help you to achieve this. What do you think @winzou @robinvdvleuten ? |
Hi there,
First of all props for the amazing library! It works perfectly with states as string. But in my use case, I would like to store some additional data alongside the state of the object like the datetime of when the object has transitioned to state.
To store such information, I made the state an entity instead of a string. And by overriding the new
getStateForTransitionmethod in my own StateMachine class, I can return an object instead of a string. To add data to the state object, you can pass an additional array.Hopefully you'll like the idea :-) otherwise you have some thoughts how I can resolve this with your library.