-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] Namespacing actions #170
Comments
I've been playing around with the idea of passing an object to connect where the property is a "namespace" and the value are the actions. So to pick up the previous example: ...
const actions = {
'itemActionsFoo': itemActions,
'authActionsBar': authActions
};
const Connected = connect('item, auth', actions)(PleaseConnectMe);
... And then in PleaseConnectMe i can do: this.props.itemActionsFoo.reset(); Any thoughts? I've made a POC here where I expose a "namespaceConnect" function: |
The trick here is that it becomes difficult to memoize |
Hello,
When using actions I see two problems.
Sure, we could combine those two and merge into one object by borrowing the excellent
combineActions
fromredux-zero
https://github.com/redux-zero/redux-zero/blob/3d0b032c0f3c94757e307673d46e9c52327f3b75/src/utils/combineActions.ts
But problem this time is if both
itemActions
andauthActions
have areset
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 ofthis.props.actionName
.Would there be any cons with above aproach?
The text was updated successfully, but these errors were encountered: