matthewmueller / matthewmueller/socrates

Dispatching multiple actions in parallel throws an error

Open
#21 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
572
Forks
14
PR merge metrics
No merged PRs in 30d

Description

According to the docs, it should be possible to dispatch multiple actions in parallel by passing an array of actions to the store:

// dispatch multiple object in parallel
socrates([
  { type: 'change:name', payload: { name: 'an' }},
  { type: 'change:age', payload: { age: 26 }}
])

But when I attempt this, I get the following redux error:
Error: Actions must be plain objects. Use custom middleware for async actions.


My code:

const slots = { /* a plain object */ }
    , exceptions = { /* a plain object */ };

store([
  { type: "set:slots", payload: slots },
  { type: "set:exceptions", payload: exceptions },
]);

Running each action individually works without issue:

store("set:slots", slots);
store("set:exceptions", exceptions);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the array-dispatch example from the issue and trace the store's dispatch entry point. The fix is done when multiple plain-object actions dispatch without the Redux error while the existing individual action calls continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.