keep-vue
Version:
Keep Vue is an open-source component library built on top of Vue3 and Tailwind CSS. It offers a collection of pre-designed UI components and styles that you can easily integrate into your web applications.
17 lines (16 loc) • 593 B
JavaScript
import { createInjectionState } from "@vueuse/core";
import {} from "vue";
// custom injectionKey
const AccordionStoreKey = "accordion-store";
const [useProvideAccordionStore, useAccordionStore] = createInjectionState((flush) => {
return { flush };
}, {
injectionKey: AccordionStoreKey,
});
export { useProvideAccordionStore };
export function useAccordionStoreOrThrow() {
const accordionStore = useAccordionStore();
if (accordionStore == null)
throw new Error("Please call `useProvideAccordionStore` on the appropriate parent component");
return accordionStore;
}