反应原生alt通量不能绑定动作存储

时间:2016-01-18 17:02:42

标签: javascript react-native flux

我有一个看起来像这样的LoginActions.js文件:

'use strict';

import alt from '../alt';
import LoginUtils from '../utils/login';

class LoginActions {

  loginSuccess(me) {
    return me;
  }

  loginFailed(err) {
    return err;
  }

  loginCancelled() {
    return function (dispatch) {
      dispatch()
    }
  }

  logout() {
    return function (dispatch) {
      dispatch()
    }
  }

  login() {
    return (dispatch) => {
      dispatch()
      LoginUtils.facebook((err, me) => {
        if (err === 'cancelled') {
          return this.loginCancelled();
        }
        if (err) {
          return this.loginFailed(err);
        }
        this.loginSuccess(me);
      });
    }
  }
}

export default alt.createActions(LoginActions);

一个看起来像这样的商店:

'use strict';

import alt from '../alt';
import _ from 'lodash';

import LoginActions from '../actions/LoginActions';
// import MeActions from '../actions/MeActions';
import CachedStore from './CachedStore';

class MeStore extends CachedStore {

  constructor () {
    super();

    this.me = {};

    this.bindListeners({
      handleLoginSuccess: LoginActions.LOGIN_SUCCESS,
      handleLoginFailed: LoginActions.LOGIN_FAILED,
      handleLogout: LoginActions.LOGOUT,
      handleLogin: LoginActions.LOGIN,
      handleLoginCancelled: LoginActions.LOGIN_CANCELLED
    });
  }

... // all handlers are defined here

然而,我不明白为什么我有以下错误... 我按照此处说明的步骤进行了操作:https://github.com/goatslacker/alt

enter image description here

2 个答案:

答案 0 :(得分:0)

为什么使用handleLoginSuccess: LoginActions.LOGIN_SUCCESS, 当您在Actions中登录成功的函数名是loginSuccess?

尝试handleLoginSuccess: LoginActions.loginSuccess

答案 1 :(得分:0)

好的,所以我通过删除LoginActions.js文件并从头开始一个完全相同的新文件来实现它...无法解释为什么它不起作用。