【发布时间】:2016-04-23 22:43:53
【问题描述】:
我有一个如下所示的 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
【问题讨论】:
标签: javascript react-native flux