Skip to content
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

Support nested child action creation #388

Open
dlopuch opened this issue Aug 3, 2015 · 1 comment
Open

Support nested child action creation #388

dlopuch opened this issue Aug 3, 2015 · 1 comment

Comments

@dlopuch
Copy link

dlopuch commented Aug 3, 2015

A Flux-ism is to have a single global list/registry of actions. When you have a single list, it's useful to have several levels of nesting. I would love to have something like:

var actions = Reflux.createActions({
  foo: {
    children: [
      'subFoo1', 
      { 
        actionName: 'subFoo2', 
        children: ['subFoo2a', 'subFoo2b']
      }
    ]
  }, 
  baz: 'baz'
});

so that I could call something like actions.foo.subFoo2.subFoo2a(...)

The action creator does recursively iterate, but the key is just the json-ification of the Object -- the subaction exists, but it's at actions.foo['[object Object]'].subFoo2a()

Probably a one-liner at: https://github.com/reflux/refluxjs/blob/v0.2.11/src/createAction.js#L44 -- just change it to var name = _.isObject(definition.children[i]) ? definition.children[i].actionName : definition.children[i]; Haven't tested extensively though

@devinivy
Copy link
Contributor

devinivy commented Feb 2, 2016

While this does generalize action creation in an interesting way, I personally think this makes the API more confusing than necessary. I would personally push back against this feature, but I'd like to open the discussion up again. This sounds like a good Reflux plugin or helper.

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

No branches or pull requests

3 participants