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
It is sometimes useful the have the same meta attributes in both the pending and fulfilled actions when using createAsyncThunk.
A solution to this could be to add the result of getPendingMeta to the thunkAPI argument, so the payload creator can use it without needing to recompute it again.
I looked at the source code and it seems easy to use a variable for the getPendingMeta result and add it to thunkAPI above.
Another solution would be to have a way to add a meta attribute to every action (and not only pending).
In our use-case, we are using a middleware to handle displaying a page-wide loading bar when some actions are loading remote data. It would be useful to be able to do something like this:
getMeta: ({arg: { id }},{ getState })=>({showLoadingBar: true,locked: getState().accounts.get(id)?.locked||false,}),
The showLoadingBar would be used by the middleware, and the locked attribute is needed for both pending and fulfilled in the reducer.
The text was updated successfully, but these errors were encountered:
It is sometimes useful the have the same meta attributes in both the
pending
andfulfilled
actions when usingcreateAsyncThunk
.A solution to this could be to add the result of
getPendingMeta
to thethunkAPI
argument, so the payload creator can use it without needing to recompute it again.I looked at the source code and it seems easy to use a variable for the
getPendingMeta
result and add it tothunkAPI
above.Another solution would be to have a way to add a
meta
attribute to every action (and not onlypending
).In our use-case, we are using a middleware to handle displaying a page-wide loading bar when some actions are loading remote data. It would be useful to be able to do something like this:
The
showLoadingBar
would be used by the middleware, and thelocked
attribute is needed for bothpending
andfulfilled
in the reducer.The text was updated successfully, but these errors were encountered: