Fluxapp uses namespaced actions, and handles both async and sync responses using bluebirds Promise API.

Action Lifecycle

When an action is invoked if successful it invokes the handler, emits a before event, the actual event response and finally the after event.

In the event an event fails, throws or promise is rejected, the lifecycle changes to before and failed.

Given this examlple action

fluxapp.registerActions('user', {
  login: function() {
    return {
      id: 1
    };
  },
  
  logout: function() {
    throw new Error('No logging out allowed');
  }
});
React.createClass({
  mixins: [fluxapp.mixins.component],
  
  flux: {
    actions: {
      onUserLogoutFailed: 'user.logout:failed'
    }        
  },
  
  handleLogin: function() {
    var userAction = this.getActions('user');
    
    userActions.login();
  },
  
  handleLogout: function() {
    var userAction = this.getActions('user');
    
    userActions.logout();
  }
});

userActions.login Lifecycle

📘

Stores receive second parameter

When stores bind to the action they also provide a secondary parameter that contains the converted action type that allows them to process multiple similar actions.

Action Type (string)

Action Type (converted)

Listener parameters

user.login:before

USER_LOGIN_BEFORE

user.login

USER_LOGIN

  1. Action resolved result

user.login:after

USER_LOGIN_AFTER

userActions.logout Lifecycle

Action Type (string)

Action Type (converted)

Listener parameters

user.logout:before

USER_LOGOUT_BEFORE

user.logout:failed

USER_LOGOUT_FAILED

  1. Reason for the failure

📘

On to Action Types