Skip to content

Commit

Permalink
fix: fix the name of mapWatcher in type.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
JOU-amjs committed Nov 21, 2023
1 parent d290c51 commit fe1389f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as mapAlovaHook } from './mapAlovaHook';
export { default as mapWatcher } from './mapWatcher';
export { default as VueOptionsHook } from './stateHook';
42 changes: 41 additions & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,45 @@ interface VueHookMapperMixin<GR extends UseHookCallers> {
*/
declare function mapAlovaHook<GR extends UseHookCallers>(mapGetter: UseHookMapGetter<GR>): VueHookMapperMixin<GR>[];

/** vue options statesHook */
type VueWatchHandler = WatchOptionsWithHandler<any> | WatchHandler<any>;
type AlovaWatcherHandlers = Record<string, VueWatchHandler | Record<string, VueWatchHandler>>;

/**
* 映射状态到watch对象上,使用方法如下
* @example
* ```js
* import { mapWatcher } from '@alova/vue-options';
*
* export default {
* watch: {
* ...mapWatcher({
* // 映射单个watcher
* 'hookState1.loading'(newVal, oldVal) {},
* hookState1: {
* loading(newVal, oldVal) {},
* data(newVal, oldVal) {},
* },
*
* // 映射多个watcher
* 'hookState1.data, hookState2.data'(newVal, oldVal) {},
* 'hookState1, hookState2': {
* data(newVal, oldVal) {},
* },
* hookState2: {
* 'loading, data'(newVal, oldVal) {},
* },
* 'hookState1, hookState2': {
* 'loading, data'(newVal, oldVal) {},
* },
* })
* }
* }
* ```
* @param watcherHandlers watcher函数对象
*/
declare function mapWatcher(watcherHandlers: AlovaWatcherHandlers): Record<string, WatchOptionsWithHandler<any>>;

/**
* vue options statesHook
*/
declare const VueOptionsHook: StatesHook<unknown, unknown>;

0 comments on commit fe1389f

Please sign in to comment.