Suppose I have a ViewModel with 100 props. Currently I need a one handler that will be called if any of the props changes. Of course I can write 100 .subscribe for every property, but it seems, that there is a better way. Like in C#, where you can bind to PropertyChanged event of the model, and then choose properties of interest by their names.
Share
The general answer is to create a dependentObservable that subscribes to everything. This can be easily accomplished by doing a
ko.toJS(viewModel)inside of a dependentObservable, as it will recursively unwrap all observables. You will want to take caution to not include yourself in theko.toJScall or you can get into an infinite loop.If you are looking for something with a little more functionality, then take a look at this post.