UNPKG

@bitrix24/b24ui-nuxt

Version:

Bitrix24 UI-Kit for developing web applications REST API for NUXT & VUE

29 lines (28 loc) 615 B
import { ref, computed, isRef } from "vue"; export const useLoading = (_key, options = {}, { loading = ref(false) } = {}) => { const elLayout = ref(null); const opts = computed(() => ({ ...isRef(options) ? options.value : options })); const isLoading = computed({ get: () => { if (isRef(loading)) { return loading.value; } return false; }, set: (value) => { if (isRef(loading)) { loading.value = value; } } }); const load = (value) => { isLoading.value = value === true; }; return { elLayout, isLoading, load }; };