plrenaudin / svelte-storez

Svelte writable store with some extras
https://codesandbox.io/s/storez-demo-c11v9
28 stars 1 forks source link

Storing objects on stores (history) #9

Open sinedie opened 3 years ago

sinedie commented 3 years ago

Hey there.

Every time you save a version on the history to enable undo and redo functionality you are coping the whole store value multiple times. When storing huge objects in a store you gonna consume a lot of memory. Could be a good idea to just store what changed, like deltas with jsondiffpatch or others (or you can create an own format for the deltas) and recreate the deltas when needed. This can even erase the need for a history size, maybe?

** +2 cents: You can use a proxy like here (and other libraries I saw) and get the changes before it is even done or check the diferences between two versions recursively.

Could be a good enhancement. Idk, think about it

plrenaudin commented 3 years ago

Thanks, that is a good point but I have no time to work on this atm. If you find the courage to dive in I'd be more than happy to accept contributions :+1: