mbest / knockout-deferred-updates

Deferred Updates plugin for Knockout <=3.3.0
http://mbest.github.io/knockout-deferred-updates/
134 stars 23 forks source link

Deferring plain-old observable updates #1

Closed 88kami88 closed 12 years ago

88kami88 commented 12 years ago

Can deferred updates handle the following scenario? If not, I'm considering forking.

myObservable(newValue);

Imagine a paged list of items with a search filter. When you switch pages you switch pages, your updating the pageNumber observable. When the filter updates, you're updating the filter observable, but also calling:

pageNumber(1);

Then there's a third computed observable (called query) that returns the wrapped values of both the filter and current page to a client that will make an ajax call. The client has subscribed to query, but when you update the filter, query updates twice (once because filter has changed and once because pageNumber has been changed by the filter subscribe).

Here's a jsfiddle for the scenario: http://jsfiddle.net/edUxS/9/

Thanks.

mbest commented 12 years ago

I took your fiddle and added my plugin: http://jsfiddle.net/mbest/edUxS/10/

I think it does what you want.

88kami88 commented 12 years ago

Didn't realize I wouldn't even need to alter the call to computed. This is slick. Thanks.