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

Working with ko.computed #9

Closed
brianmhunt opened this issue Dec 29, 2013 · 2 comments
Closed

Working with ko.computed #9

brianmhunt opened this issue Dec 29, 2013 · 2 comments

Comments

@brianmhunt
Copy link

It would seem that the functions this plugin provides (.map and .filter) are not added to ko.computed, however I was wondering: How difficult would it be to make such work?

Just curious.

Cheers.

@SteveSanderson
Copy link
Owner

Computed properties don't natively raise arrayChange notifications, so KO-projections wouldn't be able to detect their changes efficiently. However you can pipe an array-valued computed property into a real ko.observableArray and then use the map/filter functions on it, e.g.:

var myObservableArray = ko.observableArray(myArrayValuedComputed());
myArrayValuedComputed.subscribe(myObservableArray);

Now myObservableArray is a real observable array (so you can map/filter it), and it will be updated whenever myArrayValuedComputed changes.

@brianmhunt
Copy link
Author

Thank you, Steve. That is a helpful suggestion. Cheers.

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