UNPKG

@cran/vue.use

Version:

Cranberry Vue Use Utilities

15 lines (14 loc) 502 B
import { createUseFactory } from "../utility/createUseFactory"; import { ref } from "@vue/runtime-dom"; export const useAppState = createUseFactory("useAppState", async function useAppStateFactory() { const appState = ref(); function update(next) { appState.value = next; } const { App: app, } = await import("@capacitor/app"); await Promise.all([ app.addListener("appStateChange", update), app.getState().then(update), ]); return { appState, }; });