mirror of
https://github.com/nasa/openmct.git
synced 2025-03-18 10:05:22 +00:00
[API] Synchronize view to model
This commit is contained in:
parent
4a50f325cb
commit
370b515c23
@ -106,6 +106,10 @@ define([
|
|||||||
var persistence = domainObject.getCapability('persistence');
|
var persistence = domainObject.getCapability('persistence');
|
||||||
return persistence.persist();
|
return persistence.persist();
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
observe: function (domainObject, callback) {
|
||||||
|
var mutation = domainObject.getCapability('mutation');
|
||||||
|
return mutation.listen(callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
TodoView.prototype.show = function (container) {
|
TodoView.prototype.show = function (container) {
|
||||||
|
this.destroy();
|
||||||
|
|
||||||
this.$els = $(todoTemplate);
|
this.$els = $(todoTemplate);
|
||||||
this.$buttons = {
|
this.$buttons = {
|
||||||
all: this.$els.find('.example-todo-button-all'),
|
all: this.$els.find('.example-todo-button-all'),
|
||||||
@ -40,9 +42,15 @@ define([
|
|||||||
|
|
||||||
this.initialize();
|
this.initialize();
|
||||||
this.render();
|
this.render();
|
||||||
|
|
||||||
|
mct.verbs.observe(this.domainObject, this.render.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
TodoView.prototype.destroy = function () {
|
TodoView.prototype.destroy = function () {
|
||||||
|
if (this.unlisten) {
|
||||||
|
this.unlisten();
|
||||||
|
this.unlisten = undefined;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TodoView.prototype.setFilter = function (value) {
|
TodoView.prototype.setFilter = function (value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user