Created
February 12, 2019 19:46
-
-
Save estevaolucas/d3a66532b1547f0d15a1d94a84b05f03 to your computer and use it in GitHub Desktop.
add a setNetworkActivityIndicatorVisible to every react-native fetch operations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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