-
Notifications
You must be signed in to change notification settings - Fork 330
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
Reflux.createActions needs more work? #14
Comments
1: Could you provide an example of how you mean or how our API should look like for this? I have some trouble visualizing this. 2: I like the hooks, we should totally have that. |
For (1): var statusUpdate = Reflux.createAction('statusUpdate'),
statusEdited = Reflux.createAction('statusEdited');
// statusEdited unregisters its own EventEmitter, and registers to
// statusUpdate's EventEmitter.
// Any and all actions beyond the first parameter is merged to the context of
// the action within the first parameter.
Reflux.combineActions(statusUpdate, statusEdited, ...);
// support arrays?
Reflux.combineActions([statusUpdate, statusEdited]);
var Actions = Reflux.createActions([
"statusEdited",
"statusAdded"
]);
// add statusUpdate (and others) to a context/namespace group
Reflux.combineActions(Actions, statusUpdate, ...);
// ideally, parameters to Reflux.combineActions(...) may be any combination of
// single actions or any context/namespace groups |
I'm a bit confused to why a user wants to combine actions. What will happen when one action is invoked, will other actions in that group be invoked as well? By original design, they're supposed to be independent emitters and if component wants to invoke many actions they should invoke them seperate from each other and let the deferring do the rest. I feel this looks a lot like If it is only for grouping actions together then just create actions as usual and put them in different object literals that will serve as namespace: var Group1 = {
doFoo: Reflux.createAction(),
doBar: Reflux.createAction()
};
var Group2 = {
doBaz: Reflux.createAction()
}; If you need to unregister actions from a "namespace" that a component uses then we do actually have the Is there something I'm missing with your proposal? |
Hmmm, I refactored a bit, and it doesn't seem to make sense to dynamically add/remove actions within a namespace. My original goal was to have |
@spoike I think we can scrap the idea of dynamically combining/splitting actions. Edited the first post. |
@dashed Ok, cool. |
Closing this since I created an ticket #16 for the second part of this issue. |
PR at #13 is a baby step; which shares EventEmitter among group of actions.
This allows the possibility of certain features:
1. Should we bother adding/removing actions to/from context/namespace/group of actions?-
May need to use
Object.defineProperty
for custom getter/setters to register/unregister to the namespace's EventEmitter. Since react.js supports IE8,Object.defineProperty
will need to be polyfilled.Assign hook functions when calling actions. Hook functions get executed before/after each emit.
Inspired by mount lifecycle of react.js.
Proposed example:
The text was updated successfully, but these errors were encountered: