Multiple PriceFeed subscriptions

This commit is contained in:
Aleksandr Kraiz
2022-05-22 23:15:30 +04:00
parent 5ffc5ed00c
commit 9c3455e1b2
4 changed files with 66 additions and 52 deletions

View File

@@ -347,33 +347,30 @@ orionUnit.orionAggregator.ws.unsubscribe("btasabu");
## Price Feed Websocket Stream
> :warning: **Currently supported only one subscription per subscription type**
```ts
orionUnit.priceFeed.ws.subscribe(
"allTickers",
(tickers) => {
const allTickersSubscription = orionUnit.priceFeed.ws.subscribe("allTickers", {
callback: (tickers) => {
console.log(tickers);
},
undefined
);
orionUnit.priceFeed.ws.unsubscribe("allTickers");
});
allTickersSubscription.unsubscribe();
orionUnit.priceFeed.ws.unsubscribe("allTickers", allTickersSubscription.id); // Also you can unsubscribe like this
orionUnit.priceFeed.ws.subscribe(
"ticker",
(ticker) => {
const tickerSubscription = orionUnit.priceFeed.ws.subscribe("ticker", {
callback: (ticker) => {
console.log(tricker);
},
"ORN-USDT"
);
orionUnit.priceFeed.ws.unsubscribe("ticker");
payload: "ORN-USDT",
});
tickerSubscription.subscription();
orionUnit.priceFeed.ws.unsubscribe("ticker", tickerSubscription.id);
orionUnit.priceFeed.ws.subscribe(
"lastPrice",
({ pair, price }) => {
const lastPriceSubscription = orionUnit.priceFeed.ws.subscribe("lastPrice", {
callback: ({ pair, price }) => {
console.log(`Price: ${price}`);
},
"ORN-USDT"
);
orionUnit.priceFeed.ws.unsubscribe("lastPrice");
payload: "ORN-USDT",
});
lastPriceSubscription.unsubscribe();
orionUnit.priceFeed.ws.unsubscribe("lastPrice", lastPriceSubscription.id);
```