-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathgenerated-apis.js
30 lines (26 loc) · 1.02 KB
/
generated-apis.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
const createSession = require('../../session');
createSession().open().then((global) => global.getActiveDoc().then((doc) => {
console.log('Document: API fetched');
const update = () => {
// We end the example once we get another change on the document, when a
// session is closed, all generated APIs will have their 'closed' event
// emitted:
doc.on('changed', () => doc.session.close());
doc.getAppLayout().then(() => {
console.log('Document: Layout fetched');
doc.getAppProperties().then((props) => {
props.test = true;
// Modifying the properties will trigger another change:
doc.setAppProperties(props);
});
});
};
doc.on('changed', () => console.log('Document: changed'));
doc.on('closed', () => console.log('Document: closed'));
// Newly generated APIs is in a 'changed' state so we trigger our update logic
// manually the first time:
update();
})).catch((error) => {
console.log('Session: Failed to open socket:', error);
process.exit(1);
});