-
Notifications
You must be signed in to change notification settings - Fork 91
Closed
Description
Hi there,
Thanks for provider this awesome lib, l like the api very much.
I have a situation that in a list page, there will be 3 api calls:
- loads all the list items when page loads.
- batch update selected items status, when success should reload the list items
- another batch update action.
I use following code to implement above logic
const {data, isLoading, reload} = useAsync({promiseFn: loadAllItems, query: query, watch: "...."})
// query is from url params, there is a filter bar to update this. i use watch update auto reload.
const handleBatchUpdateSuccess = () => {
mesasge.info("success")
reload()
}
const {run: batchUpdate} = useAsync({deferFn: batchUpdateItems, onResolve: handleBatchUpdateSuccess})
const {run: anotherBatchUpdate} = useAsync({deferFn: anotherBatchUpdateItems, onResolve: handleBatchUpdateSuccess})
Problems occurs as following:
- Refresh the page, so all the data reloads, we say it's the filter1
- Change the filter, so the data reloaded, we say it's the filter2
- use the batchUpdate action, then page reload again. but the reload is using the filter1 instead of filter2.
I've tried to not use onResolve, but using the onEffect to watch the batchUpdateLoading to fire the same callback(handleBatchUpdateSuccess
), and it's act as expected.
So i guess whether there are some machism that cached the onResolve callback.
Metadata
Metadata
Assignees
Labels
No labels