actives
Version:
actives - pure logic (PL) - pure view (PV)
38 lines (28 loc) • 799 B
JavaScript
let Connection = require('./Connection');
module.exports = class DefinitionConnection extends Connection {
constructor(name, service, definition) {
super(name, service);
this.definition = definition;
this.context = undefined;
}
notify(box, event) {
if (event.type == 'CONNECTION_INIT') {
box.get(this.service);
}
this.notifyIt(box, event);
}
getStateContext(box) {
if (!this.context) {
this.context = box.context({
[this.service]: () => this.getOriginValue()
});
}
return this.context;
}
getValue() {
return this.definition.getValue();
}
getOriginValue() {
return this.definition.getOriginValue();
}
}