You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In append mode, you can specify the parameter of `refresh` as a list item. When the same reference of this list item is found, the data of the page number where this list item is located will be refreshed.
@@ -638,8 +639,9 @@ It will clear all caches and reload the first page.
638
639
```typescript
639
640
/**
640
641
* Reload the list from the first page and clear the cache
642
+
* @returns [v3.1.0+]an promise instance that indicate if the reset is successful
641
643
*/
642
-
declarefunction reload():void;
644
+
declarefunction reload():Primise<void>;
643
645
```
644
646
645
647
## Compatible with `updateState`
@@ -705,14 +707,14 @@ Inherit all responsive data from [**useWatcher**](/api/core-hooks#usewatcher).
705
707
706
708
Inherit all action functions of [**useWatcher**](/api/core-hooks#usewatcher).
707
709
708
-
| name | description | function parameters | return value | version |
| refresh | Refresh the data of the specified page number, this function will ignore the forced sending request of the cache, in the append mode, the list item can be passed in to indicate the page number where the list item is refreshed | pageOrItemPage: Refreshed page number or list item |- | - |
711
-
| insert | Insert a piece of data. If no index is passed in, it will be inserted at the front by default. If a list item is passed in, it will be inserted after the list item. If the list item is not in the list data, an error will be thrown | 1. item: insert item<br/>2. indexOrItem: insert position (index) or list item, default is 0 | - | - |
712
-
| remove | Remove a piece of data. When a number is passed in, it means the removed index. When the position is passed in a list item, the list item will be removed. If the list item is not in the list data, an error will be thrown | position : remove position (index) or list item | - | - |
713
-
| replace | Replace a piece of data. When the second parameter is passed in a number, it means the replacement index. A negative number means counting from the end. When the position passed in is a list item, the list item will be replaced. If the list item is not in the list data An error will be thrown | 1. item: replacement item<br/>2. position: replacement position (index) or list item, when a negative number is passed in, it means counting from the end | - | - |
714
-
| reload | Clear the data and re-request the first page of data | - |-| - |
715
-
| update | Update state data, same as alova's use hook, but update list data when updating data field | newFrontStates: new state data object | - | - |
710
+
| name | description | function parameters | return value | version |
| refresh | Refresh the data of the specified page number, this function will ignore the forced sending request of the cache, in the append mode, the list item can be passed in to indicate the page number where the list item is refreshed | pageOrItemPage: Refreshed page number or list item |Promise\<AG\['Responded'\]\>| v3.1.0+|
713
+
| insert | Insert a piece of data. If no index is passed in, it will be inserted at the front by default. If a list item is passed in, it will be inserted after the list item. If the list item is not in the list data, an error will be thrown | 1. item: insert item<br/>2. indexOrItem: insert position (index) or list item, default is 0 | - | - |
714
+
| remove | Remove a piece of data. When a number is passed in, it means the removed index. When the position is passed in a list item, the list item will be removed. If the list item is not in the list data, an error will be thrown | position : remove position (index) or list item | - | - |
715
+
| replace | Replace a piece of data. When the second parameter is passed in a number, it means the replacement index. A negative number means counting from the end. When the position passed in is a list item, the list item will be replaced. If the list item is not in the list data An error will be thrown | 1. item: replacement item<br/>2. position: replacement position (index) or list item, when a negative number is passed in, it means counting from the end | - | - |
716
+
| reload | Clear the data and re-request the first page of data | - |Promise\<void\>| v3.1.0+|
717
+
| update | Update state data, same as alova's use hook, but update list data when updating data field | newFrontStates: new state data object | - | - |
1. All use hooks in alova support action function delegation, but the functions delegated by different use hooks are different.
63
-
2. When using `actionDelegationMiddleware`, the delegate name can be passed in strings, numbers, and symbol values.
62
+
1. The use hook that only makes request will have its actions delegated
63
+
2. All use hooks in alova support action function delegation, but the functions delegated by different use hooks are different.
64
+
3. When using `actionDelegationMiddleware`, the delegate name can be passed in strings, numbers, and symbol values.
64
65
65
66
:::
66
67
68
+
### Silently access actions
69
+
70
+
By default, an error will be throwed when the action delegate of `testAction` is not found, which can help you locate problems, but if you are not sure whether the target actions are delegated when calling `accessAction`, you can prevent the error by passing the third parameter `true`.
71
+
72
+
```javascript
73
+
accessAction(
74
+
'testAction',
75
+
delegatedActions=> {
76
+
delegatedActions.send();
77
+
},
78
+
true
79
+
);
80
+
```
81
+
67
82
### Batch trigger action function
68
83
69
84
In the above example, we use `accessAction` to trigger the action function of a use hook, but in fact, delegates with the same name will not override each other, but will be stored in a group, and we can use this name to trigger them at the same time The delegated function.
@@ -73,7 +88,7 @@ import { actionDelegationMiddleware } from 'alova/client';
0 commit comments