kn-hooks 0.0.28 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -564,7 +564,7 @@ usePaginationWithForm的返回对象
564
564
 
565
565
  | Name | Type | Description |
566
566
  | --- | --- | --- |
567
- | reset | <code>function</code> | 重置方法 |
567
+ | reset | <code>function</code> | 重置方法,返回Promise |
568
568
 
569
569
 
570
570
  <a id="module_useswitch"></a>
@@ -55,6 +55,6 @@ usePaginationWithForm的返回对象
55
55
 
56
56
  | Name | Type | Description |
57
57
  | --- | --- | --- |
58
- | reset | <code>function</code> | 重置方法 |
58
+ | reset | <code>function</code> | 重置方法,返回Promise |
59
59
 
60
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-hooks",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "scripts": {
5
5
  "dev": "cross-env env_api=dev env_package=dev webpack-dev-server --progress",
6
6
  "build": "cross-env env_api=prod env_package=prod webpack --config webpack.config.js",
@@ -119,7 +119,7 @@ const usePagination=(props)=>{
119
119
  if(!params){return;}
120
120
  }
121
121
  }
122
- if(!params)requrn;
122
+ if(!params)return;
123
123
  console.log('[usePagination] service',params)
124
124
  let req = await service(params);
125
125
  const {afterService} = listener;
@@ -45,7 +45,7 @@ return(
45
45
  * @returns {UsePaginationWithFormResult}
46
46
  */
47
47
  const usePaginationWithForm = (props) => {
48
- const {service,pagination,...otherProps}= props;
48
+ const {service,pagination,beforeService=[],...otherProps}= props;
49
49
  const [form] = useState(props.form);
50
50
  const page = usePagination({service,pagination,...otherProps})
51
51
 
@@ -58,8 +58,14 @@ const usePaginationWithForm = (props) => {
58
58
  return params;
59
59
  };
60
60
  page.addListener('beforeService',fnFeforeService);
61
+ for(let fn of beforeService){
62
+ page.addListener('beforeService',fn);
63
+ }
61
64
  return ()=>{
62
65
  page.removeListener('beforeService',fnFeforeService);
66
+ for(let fn of beforeService){
67
+ page.removeListener('beforeService',fn);
68
+ }
63
69
  }
64
70
  },[])
65
71
 
@@ -81,7 +87,7 @@ const usePaginationWithForm = (props) => {
81
87
  if(form){
82
88
  form.resetFields();
83
89
  }
84
- page.reset();
90
+ return page.reset();
85
91
  };
86
92
 
87
93
  return {
@@ -94,7 +100,7 @@ const usePaginationWithForm = (props) => {
94
100
  /**
95
101
  * usePaginationWithForm的返回对象
96
102
  * @typedef {Object} UsePaginationWithFormResult
97
- * @property {Function} reset - 重置方法
103
+ * @property {Function} reset - 重置方法,返回Promise
98
104
  */
99
105
 
100
106