Get the list of patches #143
Unanswered
kettanaito
asked this question in
Q&A
Replies: 1 comment 4 replies
-
|
#72 is primarily about listening for changes to the draft in a manner before it's finalized. From your example, it seems you are listening for changes after the finalization is complete and a new state has been produced. This means you could consider using a shallow comparison to detect changes. For example: function isEqual(x: any, y: any) {
if (x === y) {
return x !== 0 || 1 / x === 1 / y;
} else {
return x !== x && y !== y;
}
}
const nextState = create(baseState, update);
if (!isEqual(nextState.some.nested.property, baseState.some.nested.property)) {
sideEffect();
} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to get a list of changes applied by a draft?
I'd like to check if certain properties were updated by the draft and if they were, fire some side effects. Something like:
Can I achieve this with the existing API somehow? I've seen
patchesbut that's a function meant to apply/revert the changes. Not quite what I'm looking for.#72 does sound extremely close to what I need!
Beta Was this translation helpful? Give feedback.
All reactions