-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecords.js
60 lines (47 loc) · 1.37 KB
/
records.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
57
58
59
60
const deepstream = require('deepstream.io-client-js')
const clientA = deepstream('localhost:6020').login()
const clientB = deepstream('localhost:6020').login()
const myRecordA = clientA.record.getRecord('record_name')
const myRecordB = clientB.record.getRecord('record_name')
setTimeout(() => {
console.log(
'4 usages at end of log:',
clientA.record.getRecord('record_name').usages,
myRecordA.subscribe('grandchild', printingA),
myRecordB.subscribe('grandchild', printingB),
clientA.record.getRecord('record_name').name,
clientA.record.getRecord('record_name').usages)
}, 30)
setTimeout(() => {
console.log('setting record data…')
myRecordA.set('grandchild', 'Morty')
myRecordB.set('grandchild', 'Morty')
}, 50)
setTimeout(() => {
console.log(
'getting record path:',
myRecordA.get('grandchild'))
}, 60)
setTimeout(() => {
console.log('discarding A…')
myRecordB.discard()
}, 70)
setTimeout(() => {
console.log('setting record data…')
myRecordA.set('grandchild', 'Summer')
}, 90)
setTimeout(() => {
console.log(
'getting all record data:',
myRecordA.get())
}, 170)
setTimeout(() => {
clientA.close()
clientB.close()
}, 200)
function printingA() {
console.log('A:', myRecordA.name, myRecordA.get('grandchild'))
}
function printingB() {
console.log('B:', myRecordB.name, myRecordB.get('grandchild'))
}