@ace-fetch/vue
Version:
vue adapter for @ace-fetch/core.
22 lines (21 loc) • 744 B
JavaScript
import { getCurrentInstance, inject } from 'vue-demi';
import { debug } from '@ace-fetch/core';
/**
* activeFetch must be called to handle SSR at the top of functions like
* `fetch`, `setup`, `serverPrefetch` and others
*/
export var activeFetch;
/**
* inject key
*/
export var FetchInjectKey = 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
*/
export var setActiveFetch = function (fetch) { return (activeFetch = fetch); };
/**
* Get the currently active fetch if there is any.
*/
export var getActiveFetch = function () { return (getCurrentInstance() && inject(FetchInjectKey)) || activeFetch; };