Skip to content

Call dispatch with more than one argument #682

@eugeny-dementev

Description

@eugeny-dementev

Original redux dispatch allow to pass more than one argument thats in result will be received in the middleware and all passed arguments will be logged. It's very useful and flexible. But dispatch function that passed to mapDispatchToProps handle only first argument and middleware always log array with that first argument.

// Redux 3.6.0

const middlewares = [
  function logArguments (store) {
    return next => (...args) => {
      console.log(args);

      next(...args);
    }
  }
];

const store = createStore(() => {}, applyMiddleware(...middlewares));

store.dispatch({ type: 'NOOP' }, { arg: 'second' }, { arg: 'third' });
// [ { type: 'NOOP' }, { arg: 'second' }, { arg: 'third' } ]

Actually i didn't find any documentation about this way to use dispatch so it'll be nice to also clarify that moment.

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