Skip to content

handleAction should accept an empty action i.e., {} #139

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

Closed
wants to merge 1 commit into from

Conversation

CurtisHumphrey
Copy link

I write a lot of tests like the following which work until recent changes:

describe('should have this initial state', () => {
  it('should start with no crumbs', () => {
    const next_state = reducer(undefined, {})
    expect(selectors.crumbs(next_state)).to.have.length(0)
  })
})

@BerkeleyTrue
Copy link

An action, by definition, must have a type property. There is no such thing as an empty action.

A way around this is just to create an action with type: '' and re-use it throughout your tests.

@yangmillstheory
Copy link
Contributor

Thanks @BerkeleyTrue.

This library deals specifically with Flux Standard Actions. The spec says that type is required, though I'd say this is a broader definition in Flux/Redux.

@CurtisHumphrey
Copy link
Author

CurtisHumphrey commented Oct 6, 2016

True I could create actions like {type:''} @BerkeleyTrue; however, redux itself handles actions of {} just fine so this library which is suppose to be a helper has artificial reduced redux abilities because it does not want to add about 20 chars: '''action.type == null || '''. Also this library used to handle an action of {} just fine until recent changes so to my project this is adding in backwards compatibles since the version number did not indicate breaking changes. If you going to insist on this breaking change then please update the version numbers correctly @yangmillstheory.

@JaKXz
Copy link
Contributor

JaKXz commented Oct 6, 2016

@CurtisHumphrey since redux-actions is v0.x, any minor version bump should be considered breaking according to the semver spec.

That being said, I do think it's a valid fix to handle the empty object action since that matches Redux.

@JaKXz
Copy link
Contributor

JaKXz commented Oct 6, 2016

However, the spec for FSAs mandates a type property and that's fair enough for this library to enforce (#145, #141). Thanks again @yangmillstheory! :)

@yangmillstheory
Copy link
Contributor

yangmillstheory commented Oct 6, 2016

Just to clarify the intent of this library:

image

It should be used for FSA-compliant Redux apps. As mentioned above, actions with no type are not FSA.

If you'd like to retain most of the functionality of this library, but not be FSA-compliant, you're free to fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants