import { watch } from 'vue';
import { useIDBKeyval as useIDBKeyval$1 } from '@vueuse/integrations/useIDBKeyval';
import { createEventHook } from '@vueuse/core';

const useIDBKeyval = (key, initialValue, options) => {
  const { data, isFinished, set } = useIDBKeyval$1(key, initialValue, options);
  const IDBInitResult = createEventHook();
  const initIndexedDBComplete = async () => {
    if (isFinished.value) {
      return;
    }
    return new Promise((resolve) => {
      IDBInitResult.on(resolve);
    });
  };
  watch(isFinished, (newValue) => {
    if (newValue) {
      IDBInitResult.trigger();
    }
  });
  return {
    data,
    isFinished,
    set,
    initIndexedDBComplete
  };
};

export { useIDBKeyval };
//# sourceMappingURL=index.mjs.map
