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 ability to limit how often onValuesChange fires #41

Closed
RyanMitchellWilson opened this issue Oct 6, 2017 · 5 comments
Closed

Add ability to limit how often onValuesChange fires #41

RyanMitchellWilson opened this issue Oct 6, 2017 · 5 comments

Comments

@RyanMitchellWilson
Copy link

I'm currently running some calculations every time the value changes when I'm sliding it, but I would like it to only fire the onValuesChange method a couple times every second.

Is there a way to limit this currently? I wasn't able to see anything popping out at me in the source code for this project. If not could it possibly be added?

@ptomasroos
Copy link
Owner

Not really. But yeah if you just use underscore / lodash and use the _.throttle on the callback with, 1000 as the rate it should be fine.

@ptomasroos
Copy link
Owner

Actually debounce would be better here since you're probably looking to do a calculation of the last value provided!

@ptomasroos
Copy link
Owner

@RyanMitchellWilson
Copy link
Author

That could work but I'm not exactly trying to pull in another library for this one thing but I did manage to get what I need just by setting a timestamp whenever onValueChanges runs and I only run the calculations if the two times are enough apart.

@ptomasroos
Copy link
Owner

Well done! Glad you solved it !

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

No branches or pull requests

2 participants