Skip to content
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

Closed
einarq opened this issue May 24, 2023 · 5 comments
Milestone

Comments

@einarq
Copy link

einarq commented May 24, 2023

Previously this worked fine:

yield takeEvery(cAT.fulfilled, saga);

Now we have to do this instead:
yield takeEvery(cAT.fulfilled.type, saga);

@markerikson markerikson added this to the 2.0 milestone May 24, 2023
@EskiMojo14
Copy link
Collaborator

EskiMojo14 commented May 24, 2023

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.

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.

@einarq
Copy link
Author

einarq commented May 25, 2023 via email

@EskiMojo14
Copy link
Collaborator

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

@einarq
Copy link
Author

einarq commented May 25, 2023

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.

Object.entries(actionHandlers).forEach((entry) => {
  builder.addCase(entry[0], entry[1]);
});

This no longer works unless its cAT.pending.type, only works when doing builder.addCase(cAT.pending) directly.
This is fine of course, so never mind :)

@markerikson
Copy link
Collaborator

Seems like there's nothing we need to do here, then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants