Skip to content

Return value of dispatch #61

@gaearon

Description

@gaearon

@vslinko

What should redux.dispatch() return? Currently the code is

    function dispatch(action) {
      return typeof action === 'function' ?
        action(dispatch, state) :
        dispatchSync(action);
    }

but I don't remember the circumstances when the return value of the callback form can be useful.

Because the callback form may schedule additional dispatches, it seems that the calling code still doesn't have enough information. Can we just return whatever action was passed?

    function dispatch(action) {
      if (typeof action === 'function') {
        action(dispatch, state);
      } else {
        dispatchSync(action);
      }
      return action;
    }

?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions