rusk icon indicating copy to clipboard operation
rusk copied to clipboard

explorer: refactor `onNetworkChange`

Open deuch13 opened this issue 9 months ago • 1 comments

Summary

  • [ ] onNetworkChange handles retriggering the data fetch if the network is changed. Currently only one function can be passed to it. This case creates repeated code as onNetworkChange must be called repeatedly if there is more than one function fetching data from API endpoints.
  • [ ] onNetworkChange should only be triggered when a new value for the network is detected in the appStore. Currently this hook calls the functions passed to it when the network value goes from undefined to a node address

deuch13 avatar May 13 '24 14:05 deuch13

I've thought about it and maybe it's better if we stick to how native lifecycle methods are (they accept just a single callback). So instead of:

onNetworkChange(fn1);
onNetworkChange(fn2);
onNetworkChange(fn3);

We can:

onNetworkChange(network => {
    fn1(network);
    fn2(network);
    fn3(network);
});

ascartabelli avatar May 15 '24 07:05 ascartabelli

Closing this issue as the onNetworkChange hook will be retired.

deuch13 avatar Sep 30 '24 11:09 deuch13