mirror of
https://github.com/nasa/openmct.git
synced 2024-12-18 20:57:53 +00:00
[API] Implement View
This commit is contained in:
parent
55b531bdeb
commit
a07e2fb8e5
@ -1,7 +1,24 @@
|
||||
define(['EventEmitter'], function (EventEmitter) {
|
||||
function View() {
|
||||
function View(definition) {
|
||||
var self = this;
|
||||
var state = definition.state ? definition.state() : {};
|
||||
|
||||
function render() {
|
||||
if (definition.render) {
|
||||
definition.render(self.elements(), self.model(), state);
|
||||
}
|
||||
}
|
||||
|
||||
EventEmitter.call(this);
|
||||
this.state = { elements: [], model: undefined };
|
||||
|
||||
if (definition.elements) {
|
||||
this.elements(definition.elements());
|
||||
}
|
||||
if (definition.initialize) {
|
||||
definition.initialize(this.elements(), render);
|
||||
}
|
||||
this.on('model', render);
|
||||
}
|
||||
|
||||
View.prototype = Object.create(EventEmitter.prototype);
|
||||
|
Loading…
Reference in New Issue
Block a user