@orderly.network/hooks 0.0.78 → 0.0.79

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/dist/index.js CHANGED
@@ -7,8 +7,8 @@ var useSWRMutation = require('swr/mutation');
7
7
  var useConstant = require('use-constant');
8
8
  var core = require('@orderly.network/core');
9
9
  var types = require('@orderly.network/types');
10
- var useSWRSubscription = require('swr/subscription');
11
10
  var utils = require('@orderly.network/utils');
11
+ var useSWRSubscription = require('swr/subscription');
12
12
  var ramda = require('ramda');
13
13
  var futures = require('@orderly.network/futures');
14
14
  var useSWRInfinite = require('swr/infinite');
@@ -490,30 +490,31 @@ var useTickerStream = (symbol) => {
490
490
  revalidateOnFocus: false
491
491
  }
492
492
  );
493
+ const [ticker, setTicker] = React2.useState();
493
494
  const ws = useWS();
494
- const { data: ticker } = useSWRSubscription__default.default(
495
- `${symbol}@ticker`,
496
- (key, { next }) => {
497
- const unsubscribe = ws.subscribe(
498
- // { event: "subscribe", topic: "markprices" },
499
- `${symbol}@ticker`,
500
- {
501
- onMessage: (message) => {
502
- next(null, message);
503
- }
504
- // onUnsubscribe: () => {
505
- // return "markprices";
506
- // },
507
- // onError: (error: any) => {
508
- //
509
- // },
495
+ React2.useEffect(() => {
496
+ const unsubscribe = ws.subscribe(
497
+ // { event: "subscribe", topic: "markprices" },
498
+ `${symbol}@ticker`,
499
+ {
500
+ onMessage: (message) => {
501
+ if (message.symbol !== symbol)
502
+ return;
503
+ setTicker(message);
510
504
  }
511
- );
512
- return () => {
513
- unsubscribe?.();
514
- };
515
- }
516
- );
505
+ // onUnsubscribe: () => {
506
+ // return "markprices";
507
+ // },
508
+ // onError: (error: any) => {
509
+ //
510
+ // },
511
+ }
512
+ );
513
+ return () => {
514
+ setTicker(void 0);
515
+ unsubscribe?.();
516
+ };
517
+ }, [symbol]);
517
518
  const value = React2.useMemo(() => {
518
519
  if (!info)
519
520
  return null;
@@ -533,7 +534,7 @@ var useTickerStream = (symbol) => {
533
534
  config["change"] = new utils.Decimal(ticker.close).minus(ticker.open).div(ticker.open).toNumber();
534
535
  }
535
536
  return config;
536
- }, [info, ticker]);
537
+ }, [info, symbol, ticker]);
537
538
  return value;
538
539
  };
539
540
  var useMarkPrice = (symbol) => {