xState v5 : subscribe to snapshot does not trigger when an invoked actor change state #5117
-
To persist an actor's snapshot, we use the following code from the doc: const persistedState = JSON.parse(localStorage.getItem('some-persisted-state'));
const actor = createActor(someLogic, {
snapshot: persistedState,
});
actor.subscribe(() => {
localStorage.setItem(
'some-persisted-state',
JSON.stringify(actor.getPersistedSnapshot()),
);
});
// Actor will start at persisted state
actor.start(); Our actor uses an invoked machine actor. |
Beta Was this translation helpful? Give feedback.
Answered by
davidkpiano
Nov 6, 2024
Replies: 1 comment
-
Yes, use the inspect API: actor.system.inspect(inspectionEvent => {
// This is called whenever anything happens in any actor within the system
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
florian-mollin-wanteeed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, use the inspect API:
https://stately.ai/docs/inspection