Skip to content

Commit 5368154

Browse files
author
Vitaliy Stoliarov
committed
update 'notify_ui' example
1 parent f68bf6c commit 5368154

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

examples/ws2/notify_ui.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
'use strict'
22

3-
const runExample = require('../util/run_example')
3+
const { args: { apiKey, apiSecret }, debug } = require('../util/setup')
4+
const WSv2 = require('../../lib/transports/ws2')
5+
6+
async function execute () {
7+
const ws = new WSv2({
8+
apiKey,
9+
apiSecret,
10+
transform: true
11+
})
12+
ws.on('error', e => debug('WSv2 error: %s', e.message | e))
13+
await ws.open()
14+
await ws.auth()
415

5-
module.exports = runExample({
6-
name: 'ws2-notify-ui',
7-
ws: { env: true, connect: true, auth: true, transform: true }
8-
}, async ({ ws, debug }) => {
916
ws.notifyUI({
1017
type: 'success',
1118
message: 'This is a test notification sent via the WSv2 API'
1219
})
1320

1421
debug('notification sent')
15-
})
22+
await ws.close()
23+
}
24+
25+
execute()

0 commit comments

Comments
 (0)