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
  };
};
