Skip to content

[feat] Namespacing actions #170

Description

@jschill

Hello,

When using actions I see two problems.

  1. If there are alot of actions, they kind of pollute the prop root and cause prop hell.
  2. There's no good way of using two different action objects.
import { actions as itemActions } from 'store/item/actions';
import { actions as authActions } from 'store/auth/actions';

Sure, we could combine those two and merge into one object by borrowing the excellent combineActions from redux-zero
https://github.com/redux-zero/redux-zero/blob/3d0b032c0f3c94757e307673d46e9c52327f3b75/src/utils/combineActions.ts

...
const actions = combineActions(itemActions, authActions);
const Connected = connect('item,auth', actions)(PleaseConnectMe);
...

But problem this time is if both itemActions and authActions have a reset action they will collide.

So to solve these two, would it be an idea to implement some kind of prop namespacing? Without discussing the implementation, wouldn't it be an idea to have the itemActions in the example accessible via this.props.itemActions.actionName instead of this.props.actionName.

Would there be any cons with above aproach?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions