-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
State machine's dontTransition() method #6
Comments
@uburoiubu Did you want to stay in the same state without emitting a transition? |
@zhxnlai, yes, I did. |
@uburoiubu I don't think we need an
onTransition {
logger.d("received unexpected event ${validTransition.event}")
val validTransition = it as? StateMachine.Transition.Valid ?: return@onTransition
if (validTransition.from == validTransition.to) {
logger.d("received expected event ${validTransition.event} but did not change state")
return@onTransition
}
logger.d("received expected event ${validTransition.event} and changed state")
// ...
}
|
@zhxnlai, thanks. Could you elaborate more on the convenience of Suppose I don't write the following declaration: on<Event.OnConfigChanged> { dontTransition() } then it is an invalid transition for state graph, but on the other hand, we stay in the same state. If I write it, I reenter the same state, although I write Thanks again. |
I had the same reaction and was surprised when
where it'd be nice to be able to do:
I tried to accomplish something like this using |
Actually, I was just looking at Scarlet's usages of the state machine and saw this usage
which looks like that should make this possible, so I'll play with that a bit. |
unfortunately it seems that the dontTransition() method also causes the |
I am with you @ThomasDotCodes, I do have events in my state machine, where I need to execute some code but not transition. This behaviour triggering the |
Hi, I really appreciate your implementation of state machine.
I have one question though: you have this method called
dontTransition()
which makes the state machine reenter the same state. What would be the way to workaround this and not reenter the same state? Is there something likeignoreEvent()
method?Thanks.
The text was updated successfully, but these errors were encountered: