Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idiomatically update state after fetching orderbook data #79

Open
secretshardul opened this issue Sep 5, 2021 · 0 comments
Open

Idiomatically update state after fetching orderbook data #79

secretshardul opened this issue Sep 5, 2021 · 0 comments

Comments

@secretshardul
Copy link
Contributor

secretshardul commented Sep 5, 2021

Currently context/Dex.ts and context/Token.ts use a hacky approach to update state.

const [refresh, setRefresh] = useState(0);

A useState hook explicitly for refreshing is used after new values for _ORDERBOOK_CACHE are fetched via websockets. Ideally the orderbook data itself should be stored in useState(); that way updating this value will automatically refresh the UI.

Secondly there's double fetching of same data

  1. Websocket listens to changes in bid or asks, then calls setRefesh(). The fetched value is discarded, the only purpose of this was to update the UI again.
  2. The bid and ask data is fetched again using a useAsync hook

This should be resolved by the mentioned solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant