-
Notifications
You must be signed in to change notification settings - Fork 296
Only omit payload if undefined #115
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
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? |
@@ -13,7 +13,7 @@ export default function createAction(type, payloadCreator, metaCreator) { | |||
}; | |||
|
|||
const payload = hasError ? args[0] : finalPayloadCreator(...args); | |||
if (!(payload === null || payload === undefined)) { | |||
if (payload !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use the lodash function lodash/isUndefined
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
null
payload if defined