UNPKG

vue-admin-core

Version:
25 lines (22 loc) 737 B
import limit from '../../__utils__/limit.mjs'; import subscribe from '../../__utils__/subscribeFocus.mjs'; import { onUnmounted } from 'vue'; const useRefreshOnWindowFocusPlugin = (fetchInstance, { refreshOnWindowFocus, focusTimespan = 5e3 }) => { let unsubscribe = () => { }; const stopSubscribe = () => { unsubscribe == null ? void 0 : unsubscribe(); }; if (refreshOnWindowFocus) { const limitRefresh = limit(fetchInstance.refresh.bind(fetchInstance), focusTimespan); unsubscribe = subscribe(() => { limitRefresh(); }); } onUnmounted(() => { stopSubscribe(); }); return {}; }; export { useRefreshOnWindowFocusPlugin as default }; //# sourceMappingURL=useRefreshOnWindowFocusPlugin.mjs.map