Refactor to bring the nuxt loading bar code out of the strategies

This commit is contained in:
Andrew Bastin
2020-01-16 01:25:43 -05:00
parent 2faf675c0a
commit 4b48d8a8c8
3 changed files with 9 additions and 4 deletions

View File

@@ -1,12 +1,19 @@
import AxiosStrategy from "./strategies/AxiosStrategy";
import ProxyStrategy from "./strategies/ProxyStrategy";
import FirefoxStrategy from "./strategies/FirefoxStrategy";
const runAppropriateStrategy = (req, store) => {
const sendNetworkRequest = (req, store) => {
if (store.state.postwoman.settings.PROXY_ENABLED) {
return ProxyStrategy(req, store);
}
return AxiosStrategy(req, store);
};
}
const sendNetworkRequest = (req, store) =>
runAppropriateStrategy(req, store)
.finally(() => window.$nuxt.$loading.finish());
export { sendNetworkRequest };