-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make actor.system.inspect return a subscription * Changeset
- Loading branch information
1 parent
28d437c
commit c58b36d
Showing
3 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
'xstate': minor | ||
--- | ||
|
||
Inspecting an actor system via `actor.system.inspect(ev => …)` now accepts a function or observer, and returns a subscription: | ||
|
||
```ts | ||
const actor = createActor(someMachine); | ||
|
||
const sub = actor.system.inspect((inspectionEvent) => { | ||
console.log(inspectionEvent); | ||
}); | ||
|
||
// Inspection events will be logged | ||
actor.start(); | ||
actor.send({ type: 'anEvent' }); | ||
|
||
// ... | ||
|
||
sub.unsubscribe(); | ||
|
||
// Will no longer log inspection events | ||
actor.send({ type: 'someEvent' }); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters