Skip to content

state.changed in v5 #4412

Answered by davidkpiano
adithep asked this question in Q&A
Oct 29, 2023 · 2 comments · 10 replies
Discussion options

You must be logged in to vote

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

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by adithep
Comment options

You must be logged in to vote
10 replies
@davidkpiano
Comment options

@yllan
Comment options

@zaccrites
Comment options

@yllan
Comment options

@thirtified
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants