Skip to content

Commit 17d8808

Browse files
author
Vitaliy Stoliarov
committed
uodate 'tickers' example
1 parent 6b1ecfb commit 17d8808

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

examples/ws2/tickers.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
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()
414

5-
module.exports = runExample({
6-
name: 'ws2-tickers',
7-
ws: { env: true, connect: true, transform: true }
8-
}, async ({ ws, debug }) => {
915
ws.onTicker({ symbol: 'tETHUSD' }, (ticker) => {
1016
debug('ETH/USD ticker: %j', ticker.toJS())
1117
})
@@ -16,4 +22,7 @@ module.exports = runExample({
1622

1723
await ws.subscribeTicker('tETHUSD')
1824
await ws.subscribeTicker('fUSD')
19-
})
25+
await ws.close()
26+
}
27+
28+
execute()

0 commit comments

Comments
 (0)