zewish / redux-remember

Saves and loads your redux state from a key-value store of your choice
MIT License
82 stars 5 forks source link

Add simple debounce functionality #6

Closed psychedelicious closed 1 year ago

psychedelicious commented 1 year ago

We have a use-case for debouncing calls to the persist function - we want to totally avoid persistence-related execution until there is no change to state for X ms.

The persistence process has its own overhead before the storage driver is called, and we want to debounce that, so a debounced storage driver is not an option.

I'm not sure how to get that last little bit of test coverage and it bugs me!

I'm happy to extend this to be a more full-featured debounce (comparable to lodash) if that's desired. Another idea I had was to optionally accept a persist() wrapper function - so you could just pass lodash throttle/debounce and use that to wrap the persist call.

psychedelicious commented 1 year ago

It seems index.d.ts is a build artefact, but is committed to the repo - is that intentional?

I'm the principal frontend contributor for InvokeAI, a Stable Diffusion (AI Image Generation) application. We're using redux-persist currently but want to move to a different persistence library - one that is actively maintained and, well, intelligible. redux-remember seems to be the only one that fits the bill (even I can understand it!).

To debounce persistence calls on redux-persist, I ended up patching its build directly. The repo, in its current state is, does not build, and the last release has a dependency on a malicious package that was removed from the internet. So it's really hard to work on it.

Anyways, just saying hi!

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 4893527236


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/init.ts 4 5 80.0%
<!-- Total: 10 11 90.91% -->
Totals Coverage Status
Change from base Build 4893093433: -1.05%
Covered Lines: 185
Relevant Lines: 186

💛 - Coveralls
zewish commented 1 year ago

Hi @psychedelicious, nice to meet you!

The PR looks good to me, other than some minor things which I'll fix in a subsequent release:

For now I will make a release so you can be unblocked. I'm very glad you find this library useful!

Cheers, Iskren.

P.S.: I'll also be free to start working on something new soon (finalizing quite the project right now). So in case you guys need someone who likes writing TypeScript/React/React Native/Node.js with a little bit of DevOps experience I'd be glad talk to you and your team :)

zewish commented 1 year ago

@psychedelicious, version 3.3.0 is now on npm, have fun! :)

psychedelicious commented 1 year ago

@zewish Great, thanks for your prompt review and merge.

We'd love to discuss the project!

It's in a fascinating space and we have some cool frontend and backend stuff going on - like a shiny new graph execution engine backend with node editor UI and infinite image generation canvas. We're mid-migration to this new graph backend and API, so things are in flux, but we're pretty close to feature parity with the previous backend.

We're also working on a commercial wrapper, providing additional enterprise features without compromising the strong OSS-first blood (the current commercial team was mostly hired from within the OSS project).