-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclone2.js
More file actions
24 lines (20 loc) · 810 Bytes
/
clone2.js
File metadata and controls
24 lines (20 loc) · 810 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
const { MemoryLevel } = require('memory-level');
const { clone, uuid } = require('@m-ld/m-ld');
const { MqttRemotes } = require('@m-ld/m-ld/ext/mqtt');
const config = {
'@id': uuid(),
'@domain': 'test.example.org',
genesis: false, // This clone needs clone 1 to have started
mqtt: { host: 'localhost', port: 1883 }
};
(async function () {
const meld = await clone(new MemoryLevel, MqttRemotes, config)
meld.status.subscribe(status => console.log('clone 2', 'status is', status))
meld.follow(async (update, state) => {
console.log('clone 2', 'has update', update);
const all = await state.read({ '@describe': '?id', '@where': { '@id': '?id' } })
console.log('clone 2', 'has state', all)
})
await meld.write({ '@id': 'hw2', message: 'Hello World from clone 2!' })
// ...
})();