首页 > 在一个页面上trigger action,能否在另一个页面上listenTo?

在一个页面上trigger action,能否在另一个页面上listenTo?

页面A:

class PageA extends React.Component {
    constructor(props) {
        super(props);
    }
    
    handleSubmit() {
        action.applyChange('data');
        this.props.history.goPage('B');
    }
    
    render() {
        const t = this;
        return (
            <div onClick={t.handleSubmit.bind(t)}/>
        )
    }
}

页面B:

class PageB extends React.Component {
    constructor(props) {
        super(props);
    }
    
    componentDidMount() {
        this.listenTo(action.applyChange, function(msg) {
            console.log(msg)
        })
    }
    
    render() {
        const t = this;
        return (
            <div/>
        )
    }
}

如代码所示,在A页面上trigger的action后跳转回B页面上,此时B页面能否接受到这个trigger。

环境:React 0.13.x / React-Router 1.x / Reflux
因为两个页面是从属关系,但是业务内容不一样,所以没有共享的store。

实际测试中,B页面确实可以收到这个trigger,但是放在手机上测试就不可以,怀疑是页面跳转的瞬间B页面已经加载好所以能收到,但是手机性能没这么高所以收不到。

问题:
这样设计action是否合理?
理论上B页面能否确实原子的收到?
似这种从属(B页面呼出A页面,A改好数据再返回到B页面)怎样设计合理?


确认下一些细节:

这里所说的“页面A”、“页面B”,是指实际的HTML页面,还是只是两个React组件A、B。

【热门文章】
【热门文章】