Two-Screen / symmetry

Sync objects by diffing and patching
MIT License
34 stars 3 forks source link

Why not patched on the original object or give an option #9

Closed sky0014 closed 2 years ago

sky0014 commented 2 years ago

https://github.com/Two-Screen/symmetry/blob/ef72e5e9a577c69023544c8f9ea7874daff29969/src/patch.ts#L30

I'm trying to use this library with immer, but it always returned a cloned object, so that immer won't work.

Can it patch on the original object? Thx for the great work.

stephank commented 2 years ago

We had a similar use for preserving objects in the past, but no longer needed it ourselves. So when I moved this to TypeScript, I dropped it to save hassle in the migration.

It wasn't difficult to add back, though, so I created a 0.6.1. In that version, there is a applyPatch.inPlace() that should do what you want. 🙂

sky0014 commented 2 years ago

Nice job! 😄