update static method

dynamic update(
  1. dynamic handler(), [
  2. UpdateOptions? options
])

传入一个Ref数组, 更新所有关联的Widget

handler 更新函数,里面可以收集所有的被读取和被修改的响应式对象都将被收集并执行更新操作

options 可选

如果返回false,不会触发依赖的widget更新.

Implementation

static update(handler(), [UpdateOptions? options]) {
  globalRefUpdateInstance = Update();
  var _handerResult = handler();
  List<Ref> _updateRefs = (globalRefUpdateInstance as Update).refs;
  globalRefUpdateInstance = null;
  if (options != null && options.refs != null) {
    _updateRefs = (options.refs as List<Ref>);
  }
  if (_handerResult != false && _updateRefs.length > 0) {
    //  && (_updateRefs[0] is Ref || _updateRefs[0] is RefCompute)
    _updateRefs[0]._runEffect(_updateRefs, options);
    _updateRefs[0]._runRender(_updateRefs, options);
  }
}