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

react to changes of specific observables within computed #22

Open
mbest opened this issue Jul 31, 2012 · 0 comments
Open

react to changes of specific observables within computed #22

mbest opened this issue Jul 31, 2012 · 0 comments

Comments

@mbest
Copy link
Owner

mbest commented Jul 31, 2012

The pattern is to have a computed observable in which sections could be set up to run only when specific observables change. Example:

var A = ko.computed(function(didChange) {
    var c = 0;
    if (didChange(a)) {    // `a` is an observable
        // do something when `a` has changed
        c = a() + 1;
    }
    // also do something with other observables such as `b`
    return b() + c;
});

Something like this would provide another way to deal with setting up independent bindings. And it's something that's been asked about in the forums.

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

1 participant