-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility of customising function that generates requestId in the action's meta of createAsyncThunk #743
Comments
Hmm. Yeah, I think it would be fairly straightforward to let createAsyncThunk(
'some/type',
payloadCallback,
{idGenerator: uuid4}
); If you'd like to file a PR that adds that, we can see how it looks. |
* Make `idGenerator` description consistent with other sections of docs for `createAsyncThunk` * Re-arrange tests for `idGenerator`
* Link to local documentation for nanoid rather than npm package * Update local docs for `nanoid` to reflect changes to `createAsyncThunk` options * Use nullish coalescing operator when getting requestId generator
I have passed idGenerator as mentioned above but still it take default nanoid value
but it returned .is there any issue with my implementation ? Thanks |
@codetestmg The PR that adds that option was merged, but we haven't shipped a new release yet containing that change. It's slated to go out in 1.6.0, which may take a bit because we need to finalize the RTK Query implementation and merge it back over here. |
@markerikson .Thank you so much for the quick reply. thanks for the library |
Hi! :) First of all, let me express my gratitude that this library (toolkit) had already existed back in February/March when I first re-architected some project at my current company – it's been making my life so much easier since then, and fun to use – so a big THANK YOU! 🙏😇🙇🏻♂️🙇🏻♂️
Recently though, there is one aspect/requirement that I have to fulfil in my app, which is all the network requests have to be able to be tracked by uuidv4 (to conform with the existing logging/analysis infrastructure).
As I want to make use of the RTK built-in feature as much as possible, would it be possible to add a possibility to pass a custom function other than
nanoid
(in my case, it'd beuuidv4
) to generate theaction.meta.requestId
used bycreateAsyncThunk
?This is a rather simplistic construct of how my slice would look like:
I mean, currently, to satisfy this requirement, I'm making use of
action.meta.arg.requestId
and doing the wiring when dispatching:dispatch(fetchSomething({ requestId: uuidv4() }))
. So I thought it would be nice and cleaner if this feature could be implemented per se.Thank you.
The text was updated successfully, but these errors were encountered: