We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f0e39af commit 7a58df6Copy full SHA for 7a58df6
examples/ws2/notifications.js
@@ -0,0 +1,29 @@
1
+'use strict'
2
+
3
+process.env.DEBUG = 'bfx:examples:notifications'
4
5
+const debug = require('debug')('bfx:examples:notifications')
6
+const bfx = require('../bfx')
7
+const ws = bfx.ws(2)
8
9
+const run = async () => {
10
+ ws.on('error', (err) => {
11
+ debug('error: %s', err instanceof Error ? err.stack : err)
12
+ })
13
14
+ ws.onNotification({ type: '*' }, (n) => {
15
+ debug('recv notification: %j', n)
16
17
18
+ debug('connecting...')
19
+ await ws.open()
20
+ debug('connected')
21
+ await ws.auth()
22
+ debug('authenticated, listening for notifications')
23
+}
24
25
+try {
26
+ run()
27
+} catch (e) {
28
+ console.log(`error: ${e.stack}`)
29
0 commit comments