-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Action types as symbols #4
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
Comments
I thought of that, but this kind of screws the replay thing. (AFAIK you can't serialize and then deserialize symbols.) I want to pass them around for devtools, localStorage persistence, etc. |
You're right you cannot deserialize a |
I say let's keep them strings for now and revisit if there are ways to get around (de)serialization problem. |
I might be confused here, but what do you mean by "cannot deserialize a Symbol"? const INCREMENT_COUNTER = Symbol('INCREMENT_COUNTER');
console.log(String(INCREMENT_COUNTER)); // Symbol(INCREMENT_COUNTER) Wouldn't this be perfectly ideal for Redux? The ability to have identically named action types that are namespaced. I'm absolutely hating the fear that action types are overlapping since everything is global. |
I just tried using a Symbol and thankfully it works excellent with Redux! The only error that came up was with redux-logger, so I'll narrow down the error and submit a patch (if one isn't already there). |
You can't take an array of actions that use symbols, serialise them to JSON, save to localStorage, and later deserialise and replay them in a different browser session. |
@gaearon I see what you mean, that is very true. For my use case it won't be a problem, and I've submitted a patch request for redux-logger here: LogRocket/redux-logger#106 (Sorry for spamming this particular issue, but I think it's useful for others looking to use Symbols). |
Allowing this would be awesome.
Why did you enforce
type
asstring
? (createDispatcher.js#L67)The text was updated successfully, but these errors were encountered: