UNPKG

@ace-fetch/vue

Version:

vue adapter for @ace-fetch/core.

22 lines (21 loc) 883 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getActiveFetch = exports.setActiveFetch = exports.FetchInjectKey = exports.activeFetch = void 0; var vue_demi_1 = require("vue-demi"); var core_1 = require("@ace-fetch/core"); /** * inject key */ exports.FetchInjectKey = core_1.debug ? Symbol.for('__ACE_API_FETCH_VUE__') : Symbol(); /** * Set or unset active fetch, Used in SSR and internally when calling * actions and getters * @param fetch Fetch instance */ var setActiveFetch = function (fetch) { return (exports.activeFetch = fetch); }; exports.setActiveFetch = setActiveFetch; /** * Get the currently active fetch if there is any. */ var getActiveFetch = function () { return ((0, vue_demi_1.getCurrentInstance)() && (0, vue_demi_1.inject)(exports.FetchInjectKey)) || exports.activeFetch; }; exports.getActiveFetch = getActiveFetch;