var AppDispatcher = require('../dispatcher/appDispatcher'); var UserConstants = require('../constants/userConstants'); // Define action methods var UserActions = { registerUser: function(user) { AppDispatcher.handleAction({ actionType: UserConstants.REGISTER_USER, user: user }); user.save(null, { success: function() { alert('saved!'); UserActions.registrationSuccess(); }, error: function(model, response, options) { alert('error'); console.log('error:', response); UserActions.registrationFailure(response); } }); }, registrationSuccess: function() { AppDispatcher.handleAction({ actionType: UserConstants.REGISTRATION_SUCCESS }); }, registrationFailure: function(error) { AppDispatcher.handleAction({ actionType: UserConstants.REGISTRATION_FAILURE, error: error }); } }; module.exports = UserActions;