Javascript 反应本机流量同步调度错误

Javascript 反应本机流量同步调度错误,javascript,ios,react-native,flux,dispatch,Javascript,Ios,React Native,Flux,Dispatch,我正在使用可在此处找到的程序包alt构建应用程序: 我在注销操作中出错,因为我认为是同步调度,我不知道如何使用flux的waitFor调用 这是我的密码: 通过注销呼叫查看: import ProfilStore from '../../stores/Profil'; class Profil extends Page { static route(props, title) { return { component: Profil, title: title || 'P

我正在使用可在此处找到的程序包alt构建应用程序:

我在注销操作中出错,因为我认为是同步调度,我不知道如何使用flux的waitFor调用

这是我的密码:

通过注销呼叫查看:

import ProfilStore from '../../stores/Profil';

class Profil extends Page {

static route(props, title) {
  return {
    component: Profil,
    title: title || 'Profil',
    passProps: props
  };
}

currentProfil() {
  return this.props.id || MeStore.getState().me.id;
}

getProfilState() {  
  return {
    data: ProfilStore.getState().profils[this.currentProfil()],
    loading: ProfilStore.loading(this.currentProfil())
  };
}

constructor(props) {
  super(props);

  this.state = {
    errors: []
  };
  this.state = this.getProfilState();
}

onFocus = (event) => {
  if (event.data.route.component === Profil) {
    ProfilActions.fetchProfil(this.currentProfil());
  }
}

componentWillMount() {
  ProfilStore.listen(this.onProfilsChange);
  // it can be a tab view or a pushed view
  if (!this.props.id) {
    this.props.navigator.navigationContext.addListener('didfocus', this.onFocus);
  } else {
    ProfilActions.fetchProfil(this.currentProfil());
  }
}

componentWillUnmount() {
  ProfilStore.unlisten(this.onProfilsChange);
}

onProfilsChange = () => {
  this.setState(this.getProfilState());
}

render() {
  return(
    <TouchableHighlight style={styles.logoutbutton} onPress={LoginActions.logout}>
      <Text>Logout</Text>
    </TouchableHighlight>
  );
}
}
ProfilStore.js:

'use strict';

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

export class LoginActions {

  loginSuccess(me) {
    this.dispatch(me);
  }

  loginFailed(err) {
    this.dispatch(err);
  }

  logout() {
    this.dispatch();
  }

  login() {
    this.dispatch();

    LoginUtils.facebook((err, me) => {
      if (err) {
        return this.actions.loginFailed(err);
      }

      this.actions.loginSuccess(me);
    });
  }
}

export default alt.createActions(LoginActions);
import alt from '../alt';
import _ from 'lodash';
import ProfilActions from '../actions/ProfilActions';

export class ProfilStore extends CachedStore {
constructor() {

  super();

  this.profils = {};
  this.status.profilsLoading = [];
  this.status.profilsLoadingError = {};

  this.status.profilDisplaying = [];
  this.status.profilDisplayingError = {};

  this.bindListeners({
    handleFetchProfil: ProfilActions.FETCH_PROFIL,
    handleProfilFetched: ProfilActions.PROFIL_FETCHED,
    handleProfilFetchFailed: ProfilActions.PROFIL_FETCH_FAILED,

    handleDisplayProfil: ProfilActions.DISPLAY_PROFIL,
    handleDisplayProfilFailed: ProfilActions.DISPLAY_PROFIL_FAILED,
    handleDisplayProfilSuccess: ProfilActions.DISPLAY_PROFIL_SUCCESS
  });
}

handleDisplayProfil(id) {
  this.status.profilDisplaying.push(id);
  delete this.status.profilDisplayingError[id];
}
handleDisplayProfilFailed(data) {
  _.remove(this.status.profilDisplaying, function(id) {
    return id === data.id;
  });
  this.status.profilDisplayingError[data.id] = data.err;
}
handleDisplayProfilSuccess(idProfil) {
  _.remove(this.status.profilDisplaying, function(id) {
    return id === idProfil;
  });
  this.profils[idProfil] = _.extend({}, this.profils[idProfil], {invisible: false});
}
static displayProfilError(id) {
  return this.getState().status.profilDisplayingError[id];
}
static displayProfilLoading(id) {
  return _.contains(this.getState().status.profilDisplaying, id);
}

handleFetchProfil(id) {
  this.status.profilsLoading.push(id);
  delete this.status.profilsLoadingError[id];
}

handleProfilFetched(profil) {
  this.profils[profil.id] = profil;
  _.remove(this.status.profilsLoading, function(id) {
    return id === profil.id;
  });
}

handleProfilFetchFailed(data) {
  _.remove(this.status.profilsLoading, function(id) {
    return id === data.id;
  });
  this.status.profilsLoadingError[data.id] = data.err;
}

static error(id) {
  return this.getState().status.profilsLoadingError[id];
}

static loading(id) {
  return _.includes(this.getState().status.profilsLoading, id);
}

static profil(id) {
  return this.getState().profils[id];
}

}
export default alt.createStore(ProfilStore);

谢谢

肮脏黑客可能会在调用动作调度器的位置周围包装一个setTimeout(fn,0)