taro-hooks
Version:
为 Taro 而设计的 Hooks Library
12 lines (11 loc) • 535 B
TypeScript
import type { App } from '@tarojs/taro';
import type { RecordData } from '../type';
export type Instance<T extends App> = Taro.getApp.Instance<T>;
export type GlobalData<R extends RecordData> = R;
export type SetGlobalData<R> = (key: keyof R, value: R[keyof R]) => Promise<TaroGeneral.CallbackResult>;
declare function useApp<R extends RecordData = RecordData, T extends App = App>(allDefault?: boolean): {
app: Instance<T>;
globalData: GlobalData<R>;
setGlobalData: SetGlobalData<GlobalData<R>>;
};
export default useApp;