-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpubsubMessage.js
More file actions
52 lines (43 loc) · 1.13 KB
/
pubsubMessage.js
File metadata and controls
52 lines (43 loc) · 1.13 KB
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
const pubsub = require('./pubsub');
// const PubSub = require('pubsub-js');
const pubsubMessage = function () {
this.msg = {};
this.msg.insertBefore = {};
this.msg.insertAfter = {};
this.msg.update = [];
this.msg.delete = [];
}
pubsubMessage.prototype.insertBefore = function ({
position=null,
dataArr=[]
}={}) {
this.msg.insertBefore.position = position;
this.msg.insertBefore.dataArr = dataArr;
return this;
}
pubsubMessage.prototype.insertAfter = function ({
position=null,
dataArr=[]
}={}) {
this.msg.insertAfter.position = position;
this.msg.insertAfter.dataArr = dataArr
return this;
}
pubsubMessage.prototype.update = function ({
position,
dataArr=[]
}={}) {
this.msg.update.position = position;
this.msg.update.dataArr = dataArr;
return this;
}
pubsubMessage.prototype.delete = function ({
dataArr=[]
}={}) {
this.msg.update.dataArr = dataArr;
return this;
}
pubsubMessage.prototype.publish = function (topic) { // = '') {
pubsub.publish(topic, this.msg);
}
module.exports = pubsubMessage;