Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple debounce functionality #6

Merged
merged 4 commits into from
May 5, 2023

Conversation

psychedelicious
Copy link
Contributor

  • Add simple debounce functionality
  • If persistDebounce is provided, calls to persist will be debounced by the given amount of time and not throttled
  • If it is not provided, behaviour is idential (e.g. throttle), so this is a non-breaking change
  • Add tests for it
  • Update README

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
Copy link
Contributor Author

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!

- Add simple debounce functionality
- If `persistDebounce` is provided, calls to persist will be debounced by the given amount of time and not throttled
- If it is not provided, behaviour is idential (e.g. throttle), so this is a non-breaking change

fix: revert unintentional changes to index.d.ts
@coveralls
Copy link

Pull Request Test Coverage Report for Build 4893527236

  • 10 of 11 (90.91%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.05%) to 98.947%

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

💛 - Coveralls

@zewish
Copy link
Owner

zewish commented May 5, 2023

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:

  • Code styles are on me - completely forgot to setup eslint on this one;
  • You're also right about the index.d.ts artifact - it was like that because of some legacy stuff I used it for, but it's no longer needed;
  • I will also make sure to handle the remaining code coverage stuff later on;

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 zewish added this to the 3.3.0 milestone May 5, 2023
@zewish zewish merged commit 83fe2a4 into zewish:master May 5, 2023
1 of 2 checks passed
@zewish
Copy link
Owner

zewish commented May 5, 2023

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

@psychedelicious
Copy link
Contributor Author

@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).

@psychedelicious psychedelicious deleted the feat/debounce branch May 6, 2023 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants