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

New features #14

Merged
merged 11 commits into from
Sep 28, 2015
Merged

New features #14

merged 11 commits into from
Sep 28, 2015

Conversation

lexich
Copy link
Owner

@lexich lexich commented Sep 28, 2015

  • smart extract option from actions arguments
api.actions.test(cb) 
// equvalent
api.actions.test(null, null, cb)
api.actions.test({name: "hello"}, cb) 
// equvalent
api.actions.test({name: "hello"}, null, cb)
  • prefetch option
// complex example
{
  user: "/user/info",
  profile: "/user/:name",
  changeName: {
    url: "/user/changename",
    prefetch: [
      function({actions, dispatch, getState}, cb) {
        const {user: {data: {name}}} = getState();
        name ? cb() : dispatch(actions.user(cb));
      }, 
      function({actions, dispatch, getState}, cb) {
        const {user: {data: {name}}, profile: {data: {uuid}} = getState();
        uuid ? cb() : dispatch(actions.profile({name}, cb));
      }
    ]
    options: function(url, params, getState) {      
      const {user: {data: {uuid}}} = getState();
      return { ...params, body: { ...params.body, uuid }};
    }
  }
}

@lexich lexich changed the title New features [WIP] New features Sep 28, 2015
@lexich lexich changed the title [WIP] New features New features Sep 28, 2015
lexich added a commit that referenced this pull request Sep 28, 2015
@lexich lexich merged commit 995401e into master Sep 28, 2015
@lexich lexich deleted the refactoring branch September 28, 2015 08:29
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.

None yet

1 participant