rusk
rusk copied to clipboard
explorer: refactor `onNetworkChange`
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 asonNetworkChange
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 thenetwork
is detected in theappStore
. Currently this hook calls the functions passed to it when the network value goes fromundefined
to a node address
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);
});
Closing this issue as the onNetworkChange
hook will be retired.