【发布时间】:2015-07-18 16:34:51
【问题描述】:
在组件中执行操作时,是否会破坏 Flux 模式以访问从组件内的操作创建者返回的承诺?
动作创作者
class MyActionCreators extends Marty.ActionCreators {
create() {
this.dispatch(MyActionConstants.CREATE_ACTION);
return MyActionAPI.create()
.then(res) {
this.dispatch(MyActionConstants.CREATE_ACTION_DONE);
return res;
};
}
}
评论
class MyCompoment extends React.Component {
render() {
return(
<div>
<button onChange={ this._clickAction }>Create Me!<button>
</div>
);
}
// private
_clickAction() {
MyActionCreators.create()
// Does this break Flux?
.then((res) => {
this.context.router.transitionTo('some_path', { id: res.id });
});
}
}
商店是访问上述示例中所需信息的唯一适当位置吗?
【问题讨论】:
标签: javascript reactjs flux