Skip to content

Instantly share code, notes, and snippets.

@estevaolucas
Created February 12, 2019 19:46
Show Gist options
  • Save estevaolucas/d3a66532b1547f0d15a1d94a84b05f03 to your computer and use it in GitHub Desktop.
Save estevaolucas/d3a66532b1547f0d15a1d94a84b05f03 to your computer and use it in GitHub Desktop.
add a setNetworkActivityIndicatorVisible to every react-native fetch operations.
const globalFetch = global.fetch;
global.fetch = (url: string, params: Object): Promise<*> => {
return new Promise((resolve: any => void, reject: string => void) => {
StatusBar.setNetworkActivityIndicatorVisible(true);
globalFetch(url, params)
.then(resolve)
.then(reject)
.finaly(() => {
StatusBar.setNetworkActivityIndicatorVisible(false);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment