我有一个收藏品,我想只读。我想做类似的事情,但我不知道 Mobx 是否提供了一种创建反应函数的方法。
class Store{
private _col:Mobx.Map;
...
@observable public has(id){
return _col.has(id);
}
}
我在考虑不信任客户端的游戏架构。所以我不希望我的视图直接访问_col
.
@observe
class MyView extends Component {
...
componentWillMount(){
this.id = this.props.params.id;
autorun(()=>{
this.props.store.has(this.id)
//do something smart
}
}
...
}
有什么替代方案?