Closed Odonno closed 5 years ago
I think we can allow it and let the Reduce
implementation handle that case.
My (initial) view on that point is exactly the same as mhusainisurge's: why interfere at all?
If you can allow to pass a new object()
as an action and have the reducers handle it, then null
, DBNull.Value
, 1
, etc. should be treated just the same. That's what a developer with some experience in redux would expect.
However, I can see a problem for new developers who struggle with their jobs. Any NullReferenceException is a problem, many find it hard to trace where the null come from.. Now in redux scheme, where you dispatch actions -anywhere- and they just show up in reducers, a null-action can easily cause a NRE in poorly-written reducers, and then finding the source of that action is something I believe many may have problems with.
So.. I change my opinion:
Although my first reaction was "why interfere? let it pass", and even now I still feel that's the right way to do from the point of view of "redux theory", I suppose that the best way to handle null actions is ... to ignore them.
Conceptually, a null
is nothing, or a "dont know" value, and an action sent to the store should define what to do. A Store receiving null
as action may either pass them to reducers and risk a NRE which may cause a developer some pain, or it can play along the 'nothing' concept and do nothing. No reducer fired, no state change, no store update. A nice thing would be to issue a trace-warning about a null-action received could be issued, as sending a null instead of an action is not a normal thing, but only in DEBUG builds.
Hi @quetzalcoatl
First of all, thanks for the point of view.
My first question is "should we wait for C#8 which will handle null
with ease or should we filter this value now?".
Given your point of view, I get to the conclusion that we should ask this underlying question: "did you ever experience a null
action and in what context?".
@quetzalcoatl I just re-read your post today. Seems I missed the part about a warning in debug mode when the action dispatched is null
. Seems fair and easy to add. I'll add it to my todo list for the 2.1 version.
This is now added in the version 2.1 of ReduxSimple.
Until C# forbid nullable variables/parameters (in C# 8 I think), how do we deal with
null
action?