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

Using createActions with sync and async results #206

Closed
w33ble opened this issue Jan 25, 2015 · 6 comments
Closed

Using createActions with sync and async results #206

w33ble opened this issue Jan 25, 2015 · 6 comments

Comments

@w33ble
Copy link

w33ble commented Jan 25, 2015

Currently, the createActions method doesn't handle mixing up sync and async actions well. For example, it's very nice when I have all sync actions, like so:

var actions = Reflux.createActions([ 
  'persist',
  'get',
  'update',
  'someAction',
  'anotherAction' 
])

However, as soon as I want to add an async action, this has to become an object, a bunch of the values of which are just empty objects themselves.

var actions = Reflux.createActions({
  'persist': {},
  'get': {},
  'update': {},
  'someAction': {},
  'anotherAction': {},
  'newAsyncAction': { asyncResult: true }
})

Ideally, I'd like to be able to do something like this instead:

var actions = Reflux.createActions([
  'persist',
  'get',
  'update',
  'someAction',
  'anotherAction',
  { 'newAsyncAction': {  asyncResult: true } }
])

Again, like I mentioned in #205, maybe I'm just using this wrong - if I am, please let me know the preferred way to set this up

@w33ble w33ble changed the title Using createActions with some async actions Using createActions with sync and async results Jan 25, 2015
@grabbou
Copy link

grabbou commented Feb 1, 2015

+1, would be quite useful.

@maxguzenski
Copy link
Contributor

var createActions = function() {
  return Reflux.createActions(_.reduce(arguments, function(h, v) {
    return _.isString(v) ? h[v] = {} : _.extend(h, v);
  }, {}));
};


var actions = createActions(
  'persist',
  'get',
  'update',
  'someAction',
  'anotherAction',
  { 'newAsyncAction': {  asyncResult: true } }
)

@vdemin
Copy link

vdemin commented May 15, 2015

+1

2 similar comments
@ladas-larry
Copy link

+1

@dbackeus
Copy link

+1

@BryanGrezeszak
Copy link
Contributor

This seems to work. Must have been implemented but not closed.

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

8 participants