state.changed in v5 #4412
-
In v4 we can detect if the transition is successful like so: https://xstate.js.org/docs/guides/states.html#state-changed How do I know if the event I sent is successful in v5? Is it possible currently? If not I think it will be a very useful feature. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
In XState v5, it is a simple referential equality check: let prevSnapshot;
actor.subscribe(snapshot => {
- snapshot.changed;
+ snapshot === prevSnapshot; // false if changed
prevSnapshot = snapshot;
}); cc. @Andarist |
Beta Was this translation helpful? Give feedback.
-
It really feels as if this should be a framework feature. Feels a bit weird having to manually keep track of the snapshot state of a state machine 😉. |
Beta Was this translation helpful? Give feedback.
In XState v5, it is a simple referential equality check:
cc. @Andarist