A light, backbone-like type of observer module built on ES2015.
This Observer (pub/sub) module contains basic functionality you can find in popular frameworks such as backbone.js.
Features: Features Model and View classes.
Dependencies: None.
Note: Transpile to ES5 for cross-browser compatibility.
Methods:
.set():
Add or modify data in model object. This will trigger events for all subscribed views.
Syntax 1: model.set( property, value, silent);
Syntax 2:
model.set({
Property: value,
Property: value
}, null, silent);
Note: Silent is an optional parameter that when set to true won’t fire any event.
.get():
Get value from model.
Syntax: model.set( property);
.trigger():
Forces an event trigger on model.
Syntax: model.trigger(event);
.on():
Attaches a name-spaced event to a method.
Syntax: model.on(‘change:value’, this.method);
.off():
Removes event from lists of events on model.
Syntax: model.off(‘change:value’);
Methods:
Initialize():If method initialize is declared, it will run automatically when the instance is created.
$():
Just like jQuery (and how backbone implemented it) the method this.$() is a handy shorthand for document.querySelectorAll(selector).