question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Combining Actions

See original GitHub issue

Here’s a simple utility function I’m using that merges multiple action maps together. Thought this might be worthy of adding to the core library, unless I’m missing an better approach:

export function combineActions(...actionsArray) {
  return store => (
    actionsArray.reduce((acc, actions) => {
      actions = typeof actions === "function" ? actions(store) : actions
      return Object.assign(acc, actions)
    }, {})
  )
}

Usage:

import { userActions, todoActions } from '../actions'

@connect((state, props) => {
  return state
}, combineActions(userActions, todoActions))
export class App extends Component {
  ...
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
leobetosouzacommented, Mar 15, 2018

It looks like your version won’t work with simple object actions, hence why my proposal checks for a “function” type.

@jetako Yeah, I missed it. You’re right. I haven’t noticed that we have simple object actions. I will work on it tomorrow.

1reaction
matheusmlcommented, Jan 25, 2018

Hi @jetako

This surely can be useful. Can you add a PR with this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

combineActions - redux-actions
Combine any number of action types or action creators. types is a list of positional arguments which can be action type strings, symbols,...
Read more >
Combining actions in Flow - Power Platform Community
Is there any way I can combine all of my variables in a folder or an action that will keep them all together?...
Read more >
Combining multiple actions in one view - Notarius Support
To perform combined actions: · From the My Computer view panel in ConsignO, select a folder or multiple files the same way you...
Read more >
Building Your Playbook: Add Sets With Multiple Actions
There is incredible value in running sets with multiple actions, and the options are nearly endless - here's a few to get you...
Read more >
Combining Actions - Totally Rad! Inc.
Using Actions Together. Most of the Totally Rad Actions can be combined together to create unique recipes for your images.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found