taro-hooks
Version:
为 Taro 而设计的 Hooks Library
19 lines (18 loc) • 752 B
TypeScript
import type { PromiseOptionalAction, PromiseAction, PromiseWithoutOptionAction, WithUndefind, Noop } from '../type';
export type Interval = keyof Taro.startDeviceMotionListening.Interval;
export type Motion = WithUndefind<Taro.onDeviceMotionChange.CallbackResult>;
export type Start = PromiseOptionalAction<Interval, boolean>;
export type Stop = PromiseWithoutOptionAction<boolean>;
export type Callback = (motion: Taro.onDeviceMotionChange.CallbackResult) => void;
export type Add = PromiseAction<Callback>;
export type Off = PromiseAction<Noop>;
declare function useMotion(autoListen?: boolean, interval?: Interval): [
Motion,
{
start: Start;
stop: Stop;
add: Add;
off: Off;
}
];
export default useMotion;