News for hackers. Stuff that matters.
Re:Build Yourself a Redux by fiatjaf on Friday May 05, 2017 @01:49PM (#14275360)
You see something is flawed in Redux at the point you have to pass strings (uppercase constants defined somewhere) around, import them in every file, pass them as identifiers of what you should do with each data.
Re:Build Yourself a Redux by joshwcomeau on Friday May 05, 2017 @03:17PM (#14276087)
You don't actually have to do this if it bothers you. You can just use the strings inline, but the author (and many of those using Redux) finds it helps to reduce errors, by instantly pointing out typos.

There are also patterns to reduce the import issue. For example, https://github.com/erikras/ducks-modular-redux. I prefer defining my actions with my action creators in one big index, but the point is that there is absolutely a way to mitigate this concern if it bothers you :)

Re:Build Yourself a Redux by fiatjaf on Friday May 05, 2017 @04:06PM (#14276444)
> You can just use the strings inline

Well, that would be much worse, don't you think?

My point was that having to keep identifiers to everything is silly.

Re:Build Yourself a Redux by shriek on Friday May 05, 2017 @06:21PM (#14277234)
The point of keeping identifiers is to show you the intents of an action. If any identifiers seem silly to be added then maybe they don't deserve to be going through reducers in the first place.
Re:Build Yourself a Redux by ezpg on Friday May 05, 2017 @07:01PM (#14277450)
Use Symbols instead of Strings: https://www.keithcirkel.co.uk/metaprogramming-in-es6-symbols...

See the second line of the code snippet under "Symbols are completely unique…"

Unless I have misunderstood the spec, to compare symbols you require both the reference and value. Much more preferable than passing around Strings.

Re:Build Yourself a Redux by acemarke on Friday May 05, 2017 @07:44PM (#14277669)
You _can_ use Symbols for `action.type` in Redux, but that's discouraged, because they're not serializable and thus will not work properly with time-travel debugging. See http://redux.js.org/docs/faq/Actions.html#actions-string-con... .
Re:Build Yourself a Redux by catshirt on Friday May 05, 2017 @02:03PM (#14275481)
if you use redux-actions your reducer can use an action reference directly- not its "type" string. developing this way I don't need to store references to these "constants" and they're only ever relevant when logging.
Re:Build Yourself a Redux by rexpop on Friday May 05, 2017 @04:04PM (#14276426)
Why is it flawed to use the module system to enforce references?