-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathstate-manager.js
More file actions
31 lines (27 loc) · 858 Bytes
/
Copy pathstate-manager.js
File metadata and controls
31 lines (27 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var StateManager = function (options) {
this.channelGrid = options.channelGrid;
this.stateRefs = options.stateRefs;
};
StateManager.prototype.create = function (state) {
var stateCellIndex = this.channelGrid.getCellIndex(state);
var stateRef = {
id: state.id,
tcid: stateCellIndex, // Target cell index.
type: state.type,
create: state
};
if (state.swid != null) {
stateRef.swid = state.swid;
}
this.stateRefs[state.id] = stateRef;
return stateRef;
};
// You can only update through operations which must be interpreted
// by your cell controllers (cell.js).
StateManager.prototype.update = function (stateRef, operation) {
this.stateRefs[stateRef.id].op = operation;
};
StateManager.prototype.delete = function (stateRef) {
this.stateRefs[stateRef.id].delete = 1;
};
module.exports.StateManager = StateManager;