-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add inspect API POC * Move around some things * Add invoke example * Fix test * More inspect work * Make this public * Add websocket handler * POC * Test updates * Refactor xstate.transition event * Add action inspection * Inspector * Use actorSystemId * Remove name for now * This one too * Refactor * Change communication event ot be xstate.event * Oops * Rename * There we go * Remove action stuff for now * Fix test * Tweak * Update packages/core/test/inspect.test.ts * Fix tests * Revert changes to this file * Clean up * Update packages/core/src/interpreter.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/src/interpreter.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/src/interpreter.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/src/types.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/src/types.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/src/system.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Update packages/core/src/types.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * Avoid mutating the received event (#4282) * Avoid mutating the received event * always go through the system when receiving an external event * Rename types * actorSystemId -> rootId * Un-expose actor options * private -> internal * system.sendTo -> system.relay * Move types * Avoid adding `.root` to the system object (#4284) * Update snapshots * Update tests * Simplify events * Add tests for composable logic * Revert "Add tests for composable logic" This reverts commit b44bfde. * Ugh types * Required target * Update packages/core/src/types.ts Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> * small tweaks * remove redundant error * slim down inspection events * Changeset + toObserver --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
1 parent
ddafb83
commit 13480c3
Showing
20 changed files
with
692 additions
and
92 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,37 @@ | ||
--- | ||
'xstate': minor | ||
--- | ||
|
||
You can now inspect actor system updates using the `inspect` option in `createActor(logic, { inspect })`. The types of **inspection events** you can observe include: | ||
|
||
- `@xstate.actor` - An actor ref has been created in the system | ||
- `@xstate.event` - An event was sent from a source actor ref to a target actor ref in the system | ||
- `@xstate.snapshot` - An actor ref emitted a snapshot due to a received event | ||
|
||
```ts | ||
import { createMachine } from 'xstate'; | ||
|
||
const machine = createMachine({ | ||
// ... | ||
}); | ||
|
||
const actor = createActor(machine, { | ||
inspect: (inspectionEvent) => { | ||
if (inspectionEvent.type === '@xstate.actor') { | ||
console.log(inspectionEvent.actorRef); | ||
} | ||
|
||
if (inspectionEvent.type === '@xstate.event') { | ||
console.log(inspectionEvent.sourceRef); | ||
console.log(inspectionEvent.targetRef); | ||
console.log(inspectionEvent.event); | ||
} | ||
|
||
if (inspectionEvent.type === '@xstate.snapshot') { | ||
console.log(inspectionEvent.actorRef); | ||
console.log(inspectionEvent.event); | ||
console.log(inspectionEvent.snapshot); | ||
} | ||
} | ||
}); | ||
``` |
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
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
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
Oops, something went wrong.