ZiadJ / knockoutjs-reactor

Recursively tracks changes within a view model no matter how deeply nested the observables are or whether they are nested within dynamically created array elements.
Other
74 stars 22 forks source link

Keep notifying changes for replaced objects #46

Closed bago closed 7 years ago

bago commented 7 years ago
var subModel = {
  c: ko.observable(1),
  d: ko.observable(0)
};

var subModelB = {
  e: ko.observable(0),
  f: ko.observable(1)
};

var model = {
  a: ko.observable(1),
  b: {
    g: ko.observable(0),
    h: ko.observable(0),
  },
  sub: ko.observable(subModel),
};

var w = ko.watch(model, { depth: -1, oldValues: 1, mutable: true, tagFields: true }, listener);

model.sub(subModelB);
subModel.c(4); // this is a change in a model being removed by the original tree, but still the listener is notified with this change.

Some "unwatch" is not working correctly.