-
Notifications
You must be signed in to change notification settings - Fork 0
/
operation.js
56 lines (42 loc) · 940 Bytes
/
operation.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class Operation {
constructor(type) {
this.type = type;
this.originalOperation = null;
this.client = null;
}
setOriginalOperation(op) {
this.originalOperation = op;
}
setClient(client) {
this.client = client;
}
getClient() {
return this.client;
}
clone() {
throw new Error('need to be override');
}
getOriginalOperation() {
return this.originalOperation;
}
checkState(state) {
throw new Error('need to be override');
}
applyOperation(state) {
throw new Error('need to be override');
}
doSync(state) {
throw new Error('need to be override');
}
isSyncOperation() {
return this.type === Operation.SYNC;
}
toString() {
throw new Error('need to be override');
}
static get INSERT() { return 1; }
static get DELETE() { return 2; }
static get REPLACE() { return 3; }
static get SYNC() { return 0; }
}
module.exports = Operation;