Fix: reset synced observable#571
Conversation
|
Had the same problem with multiple resets. See https://discord.com/channels/1241991273322119250/1341015670539681843/1341015675904331776 Your fix has one problem. It clones the value to reset to and thus reset will throw if json.parse or json.stringify used by clone throw. A much easier and faster solution would be to not have a reset value in the syncedOptions but a function returning the reset value. Docs would have to state that the function returning the reset value should not return the same reference. |
This PR was developed when I started having problems trying to reset a
syncedCrudobservable withsyncState.reset().syncState.reset()not updating observable's value when the initial value of a synced observable is an empty objectsyncState.reset()not updating observable's value when called multiple times (I had this issue in an Expo to-dos test page, where I set up a synced observable and added one to-do, then reset, then added one to-do again, then reset again. On the second reset, the observable's value didn't update)syncState.isLoadednot being set correctly when resetting a synced observable that didn't have thegetproperty (e.g.syncedCrudwithlistproperty)