Skip to content

@xstate/react feature request: trigger predifined events before stopping the interpreted service #1507

Answered by davidkpiano
dmitrybirin asked this question in Ideas
Discussion options

You must be logged in to vote

That should be an implementation detail, no?

For instance, if you are invoking an actor, you should specify the disposal there:

// example
// ...
{
  invoke: {
    src: (context, event) => (sendBack) => {
      // ...
      
      // disposal
      return () => {
        // do proper disposal here
      }
    }
  }
}

And when the service is stopped (service.stop() as you've mentioned) it will properly stop the invoked service.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@dmitrybirin
Comment options

@davidkpiano
Comment options

Answer selected by dmitrybirin
Comment options

You must be logged in to vote
1 reply
@dmitrybirin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants