Allowing this would be awesome.
Why did you enforce type as string? (createDispatcher.js#L67)
export const INCREMENT_COUNTER = Symbol()
export const DECREMENT_COUNTER = Symbol()
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 Symbol. I've missed that point.
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: https://github.com/fcomb/redux-logger/pull/106
(Sorry for spamming this particular issue, but I think it's useful for others looking to use Symbols).
Most helpful comment
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.