Skip to content
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

Allow per-resources defaults to be passed in via second arg #3

Closed
wants to merge 2 commits into from
Closed

Conversation

ajoslin
Copy link

@ajoslin ajoslin commented Mar 21, 2016

Use-case: createAPIActions(resources, {headers: getAuthHeaders}

Relies on shastajs/tahoe#8

@@ -3,25 +3,26 @@ import { plural } from 'pluralize'
import { Schema } from 'normalizr'
import template from 'template-url'
import reduce from 'lodash.reduce'
import extend from 'xtend'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this, es6 ... operator can merge the objects

@ajoslin
Copy link
Author

ajoslin commented Mar 22, 2016

Updated to use ES6 object spreads.

method: endpoint.method,
model: model,
collection: !endpoint.instance,
credentials: 'include'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be:

createAction({
  ...defaults,
  someProp: 123,
  anotherProp: {},
  someStuff: 456
})

You spread into existing objects, ordering is wherever you put it in the object so in this case defaults at the beginning

@yocontra yocontra closed this in 4843062 Mar 24, 2016
yocontra pushed a commit that referenced this pull request Mar 24, 2016
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.

2 participants