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

throttle issue using mapping #134

Closed
artursgirons opened this issue Feb 5, 2013 · 4 comments
Closed

throttle issue using mapping #134

artursgirons opened this issue Feb 5, 2013 · 4 comments

Comments

@artursgirons
Copy link

Problems is such - if I create ko.computed(..).extend({ throttle: 100 }) and computed is dependent on some observable array and observable items in that array, function is evaluated every time each item is changed in array ignoring "throttle". But interesting thing is that if I subscribe to this computed, subscribe is triggered only once (but still computed function is evaluated every time).

Problem can bee seen here - http://jsfiddle.net/dzjosjusuns/wc9ZS/2/
When I click top checkbox, each sub-checkbox is checked, and you can see at the top number of times ko.computed is called (every time +6)

In principle same example but without mapping (and working throttle) - http://jsfiddle.net/dzjosjusuns/wc9ZS/
When click top checkbox, each sub-checkbox is checked, and ko,computed is called only once (every time +1)

@oising
Copy link

oising commented Feb 6, 2013

If it doesn't evaluate every time, how is it going to count to 100 (your throttle limit?) before notifying dependents? It sounds like the behavior is correct, no?

@artursgirons
Copy link
Author

no. as I understand "throttle" (and that is how it works without mapping) is I create ko.computed with throttle(100ms) that depends on some property, if this property changes 10 times in 100ms ko.computed should evaluate only once (100ms after last property update) - that seems as purpose of throttle, is it not?

@sagacity
Copy link
Collaborator

sagacity commented Feb 8, 2013

This is fixed in 046fce9. @dzjosjusuns Can you confirm?

@artursgirons
Copy link
Author

Yes, great, thank you!

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

3 participants