Skip to content

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

Closed
CurtisHumphrey wants to merge 1 commit into
redux-utilities:masterfrom
CurtisHumphrey:master
Closed

handleAction should accept an empty action i.e., {}#139
CurtisHumphrey wants to merge 1 commit into
redux-utilities:masterfrom
CurtisHumphrey:master

Conversation

@CurtisHumphrey

Copy link
Copy Markdown

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
Copy Markdown

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.

@globalchubby

Copy link
Copy Markdown
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

CurtisHumphrey commented Oct 6, 2016

Copy link
Copy Markdown
Author

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

JaKXz commented Oct 6, 2016

Copy link
Copy Markdown
Contributor

@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

JaKXz commented Oct 6, 2016

Copy link
Copy Markdown
Contributor

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

@globalchubby

globalchubby commented Oct 6, 2016

Copy link
Copy Markdown
Contributor

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