Feature/Allow to set custom StateChanged event #237
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR add the functionality of registering a custom
StateChanged
event. I stumbled upon this myself on a project for a client, where I wanted to listen to a specific state change and apply logic for this specific state.Since only the
StateChanged
event is fired, I have to add all the listeners to this event and then place if statements to check if the model is equal to the model I want the logic to apply to.Example
In the event service provider I register
StateXChangedListener
to theStateChanged
event. Right now I have to do this in the listener:Another way is to use the
updating
event on the model. But this is also not ideal as I don't know which state transition has taken place.I also saw that there is an open discussion about custom events (see #215). I am not sure if this is what they mean by customised state changed event, but for me this implementation would be very useful.