0.7.5 • Published 9 years ago
mechanical-elements v0.7.5
MechanicalElements
MechanicalElements is a superset of ActuatorElements. If boundData have the same API as EventEmitter(more precisely, emit, addListener/on, removeListener/off), MechnicalElements can detect data changes and reflect them in the view.
Installing
$ npm install --save mechanical-elements
$ bower install --save mechanical-elements
Examples
const EventEmitter = require('events').EventEmitter;
class TodoListModel extends EventEmitter {
constructor(todos=[]) {
this._todos = todos;
}
add(todo) {
this._todos.push(todo);
this.emit('splice', this._todos.length, 0, 1); // event type, index, removedCount, addedCount
}
}
class TodoModel extends EventEmitter {
constructor(title, completed) {
super();
this.title = title;
this.completed = completed;
}
set(name, value) {
this[name] = value;
this.emit('update', name);
}
get(name) {
return this[name];
}
}
Or you can use sensor-objects.
const sensors = require('sensor-objects');
const todo = new sensors.Object({
title: 'title'
});
// or
class TodoModel extends sensors.Object {
constructor(title, completed) {
super({ title, completed });
}
}
0.7.5
9 years ago
0.7.4
9 years ago
0.7.3
9 years ago
0.7.2
9 years ago
0.7.1
9 years ago
0.7.0
9 years ago
0.6.11
9 years ago
0.6.10
9 years ago
0.6.9
10 years ago
0.6.8
10 years ago
0.6.7
10 years ago
0.6.6
10 years ago
0.4.2
10 years ago
0.4.1
10 years ago
0.3.1
10 years ago
0.3.0
10 years ago
0.2.0
10 years ago
0.1.1
10 years ago