-
Notifications
You must be signed in to change notification settings - Fork 88
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
Stopping machines #185
Comments
I don't think I understand the bug. You send 2 events to the service which puts it into the child machine. You then create a new service. That doesn't stop the in-flight Creating a new service doesn't "stop" the existing service. There isn't presently a way to stop a service that's already running, aside from not sending events into it any more. |
A |
@matthewp any suggestions how this can be achieved? |
Add a stop() function here: https://github.com/matthewp/robot/blob/main/machine.js#L189 that probably just sets a No, I don't think this is wrong, that's just how JavaScript works. If you don't keep a reference to an object that does stuff... it's going to keep doing stuff. I do think your example is not something you'd want to happen! That's why I suggested a stop(). However, even with a stop() it's not going to prevent the Promise from resolving. So if there are any mutations inside of the setTimeout handler those are still going to happen. Nothing we can do about that. But we can avoid the machine from continuing to change. |
@matthewp maybe you are right. |
@matthewp , since this is expected behaviour, would it be an idea to remove the I'm contemplating the addition of My current thinking is that long async/await functions probably warrant explicit steps in the state machine, though, where the side-effects of each step in the state machine could be cancelled by moving it into a "cancelled" state before the promise resolves, effectively cancelling all further (side-effect-full) processing. |
Yes that's my hesitancy to do something here, we can't actually stop in flight stuff. We can let the machine know not to proceed or trigger actions though |
Last week, I tried the pattern I suggested: I had an The workflow |
For background: ledgersmb/LedgerSMB@0418711 |
Yes, I think we don't document well enough that invoke can have extra events like that. It's just a regular state and can take abitrary events that you define. A cancel event is a great way to do this! |
Issue
Seems like interpret returns only a referense to origincal service.
So after trying to remove service or referense, service keeps running.
Reproduction
https://codesandbox.io/s/awesome-thunder-rk87mv?file=/src/index.js
The text was updated successfully, but these errors were encountered: