@nevuamarkets/poly-websockets 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,20 +24,19 @@ npm install @nevuamarkets/poly-websockets
|
|
|
24
24
|
```typescript
|
|
25
25
|
import { WSSubscriptionManager, WebSocketHandlers } from '@nevuamarkets/poly-websockets';
|
|
26
26
|
|
|
27
|
-
//
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
console.log(
|
|
32
|
-
}
|
|
27
|
+
// Create the subscription manager with your own handlers
|
|
28
|
+
const manager = new WSSubscriptionManager({
|
|
29
|
+
onBook: async (events: BookEvent[]) => {
|
|
30
|
+
for (const event of events) {
|
|
31
|
+
console.log('book event', JSON.stringify(event, null, 2))
|
|
32
|
+
}
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
onPriceChange: async (events: PriceChangeEvent[]) => {
|
|
35
|
+
for (const event of events) {
|
|
36
|
+
console.log('price change event', JSON.stringify(event, null, 2))
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Create the subscription manager
|
|
40
|
-
const manager = new WSSubscriptionManager(handlers);
|
|
39
|
+
});
|
|
41
40
|
|
|
42
41
|
// Subscribe to assets
|
|
43
42
|
await manager.addSubscriptions(['asset-id-1', 'asset-id-2']);
|