michaelcontento / redux-storage

Persistence layer for redux with flexible backends
MIT License
675 stars 50 forks source link

setTimeout around engine.save #142

Closed dannybloe closed 8 years ago

dannybloe commented 8 years ago

We are currently using redux-storage and are experiencing that it slows down our app quite significantly due to many writes (debouncing didn't help in our case). As a small experiment we put a setTimeout(.., 1000) around the engine.save() command because we only want to save stuff as soon as there is no UI thread doing anything. And lo and behold, that surely sped things up quite a bit.

Would it be possible to have this as a feature and if not, are there complications?

Cheers,

Danny

michaelcontento commented 8 years ago

But shouldn't redux-storage-decorator-debounce be the right solution for you?

import debounce from 'redux-storage-decorator-debounce'
engine = debounce(engine, 1000);

Should have the same effect as your experiment, as debounce also uses setTimeout !?

dannybloe commented 8 years ago

/me scratches his head... and tries again

michaelcontento commented 8 years ago

😂

dannybloe commented 8 years ago

Doh.. we had a too-low debounce timeout value. Ignore this :)

dannybloe commented 8 years ago

Ehm... is it possible to do a write on onBeforeUnload if it happens before the debounce timeout?

michaelcontento commented 8 years ago

You mean window.onBeforeUnload? Please file a bug with this at redux-storage-decorator-debounce