-
-
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
2.0 alpha 6: Change in behavior for redux saga subscriptions (due to removal of .toString() probably) #3471
Comments
you can use .match instead for better typing than .type can achieve: but yes, this is because the toString override was removed in #3425. essentially there aren't any use cases that shouldn't be able to be covered with .match or .type. it's neat that redux-saga included support for stringifiable action creators (it looks like redux-observable supports it in runtime but doesn't infer from it), but using .match is much less implicit and fragile (toString wouldn't work properly for non-string action types, though to be fair you're not allowed those in Redux 5 anyway) we may consider adding the toString override back to avoid breaking things unnecessarily, but better options have existed for a good while and we want to encourage using those instead going forward. |
I don't have a strong opinion on this, except to say that the removal of
toString also causes issues in reducers etc, where a cAT action is used in
extraReducers. I now need to use .type everywhere, otherwise the state
won't update.
So if you do go ahead with this change, then perhaps consider releasing a
codemod? Personally I'm fine with adapting my code, but others might not be
too happy with it, and could cause some friction perhaps.
…On Wed, May 24, 2023 at 8:53 PM Ben Durrant ***@***.***> wrote:
you can use .match instead for better typing than .type can achieve:
yield takeEvery(cAT.fulfilled.match, saga);
but yes, this is because the toString override was removed in #3425
<#3425>.
essentially there aren't any use cases that shouldn't be able to be
covered with .match or .type. it's neat that redux-saga included support
for stringifiable action creators, but using .match is much less implicit
and fragile (toString wouldn't work properly for non-string action types,
though to be fair you're not allowed those in Redux 5 anyway)
we may consider adding the toString override back to avoid breaking things
unnecessarily, but better options have existed for a good while and we want
to encourage using those instead going forward.
—
Reply to this email directly, view it on GitHub
<#3471 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABT6D6NBMXUIAWMZ2MZUMDXHZKLTANCNFSM6AAAAAAYM66ANU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
could you make a replication of extraReducers not working? the map builder specifically looks for a .type property, so it should be fine. https://github.com/reduxjs/redux-toolkit/blob/master/packages/toolkit/src/mapBuilders.ts#L158 |
So this works fine it seems, it was related to some workaround I had put in place after the deprecation of the dictionary style reducer syntax of extraReducers. I still had a dictionary of the reducers, and then this code to register them.
This no longer works unless its cAT.pending.type, only works when doing builder.addCase(cAT.pending) directly. |
Seems like there's nothing we need to do here, then? |
Previously this worked fine:
yield takeEvery(cAT.fulfilled, saga);
Now we have to do this instead:
yield takeEvery(cAT.fulfilled.type, saga);
The text was updated successfully, but these errors were encountered: