Search code examples
javascriptknockout.jsknockout-mapping-pluginknockout-2.0

Detect if a change occur in observableArray


Does anyone have idea, if it's possible to detect whenever a change occur inside observableArray while using ko mapping, this mean without having to create the model by hand?

self.items = ko.observableArray([])
var data = ko.mapping.fromJS(result)
self.items.push(data);

I would like to log any changes occurred in any property inside my array of objects.

Thanks


Solution

  • If I'm not mistaken, you should be able to use subscribe on the observable to get that information.

    See the bottom of this page for more info:

    Explicitly subscribing to observables