@action装饰是否使商店更新以异步方式工作?

时间:2018-09-19 15:00:58

标签: javascript mobx

Docs说,使用@action可以带来优化的好处。这是否意味着该方法开始与React setState()类似?

因此,例如有onChange处理程序,该处理程序从输入获取值并将其设置为存储。下面的代码能按预期工作吗?

handleChange = (e) => {
  const { target: { value } } = e;
  const newValue = Number(value);

  // this method is marked as @action and just set primitive value in store
  this.props.store.setValue(newValue);

 // produce some actions with this.props.store.value(new value expected)
 ...
}

0 个答案:

没有答案