Only omit payload if undefined#115
Conversation
Include a `null` payload if defined
|
Thanks for the contribution. I like distinguishing between I think @timche might have an opinion about this change. |
|
The ECMAScript spec distinguishes between For instance, the MDN article on Promises uses Further, a codebase that I work on uses |
|
ping @timche I'm happy to make an issue to not conflate |
|
This is a hard one imo. For example react-redux is also using I also prefer @jrasky can you please describe the problem you see with it with an example? Edit: Also, why are |
|
I don't doubt there's cases where treating The case I'm running into is where I'm using Very specifically, I don't expect that passing in There are always "more code" approaches to solving nearly any problem, my concern here is with having more correct, spec-compliant code. In other words, I want to pass |
|
For me personally, the open source/JS community is a higher source than the ECMAScript standard, because it represents how JS is actually used widely. I'd be happy if you could provide some links and I'm willing to change it, but that would also mean, it is going to be a breaking change and we have to release a major version. |
|
To be clear, I think your usage here is different from how redux-react uses null, because in the redux-actions case the value is "passed along." There's a couple things I can link you to in the standard:
redux itself treats It is a somewhat significant change, but also one that's not very difficult to work around. That being said, the codebase I'm working on and the standard both seem to indicate that |
|
I'd like to fix this with v1.0.0, also to follow semver. Everybody's fine with that? |
|
|
||
| const payload = hasError ? args[0] : finalPayloadCreator(...args); | ||
| if (!(payload === null || payload === undefined)) { | ||
| if (payload !== undefined) { |
There was a problem hiding this comment.
Could you please use the lodash function lodash/isUndefined here?
There was a problem hiding this comment.
Sure, but just consider that it does exactly the same thing: https://github.com/lodash/lodash/blob/master/lodash.js#L11878
|
Lets get this merged! We just bumped into a situation where our payload is null (explicitly) and the current behavior was surprising. |
|
Continuing in #128 to speed up the process. |
Include a
nullpayload if defined