collect method

dynamic collect()

自动收集依赖(请勿调用)

Implementation

collect() {
  if (globalRefBuilderInstance is StreamCollectFactory) {
    if (!_streamCache.contains(globalRefBuilderInstance)) {
      _streamCache.add(globalRefBuilderInstance);
    }
    if (!(globalRefBuilderInstance as StreamCollectFactory)
        .refs
        .contains(this)) {
      (globalRefBuilderInstance as StreamCollectFactory).refs.add(this);
    }
  }
  if (globalRefWatchInstance is WatchCollectFactory) {
    if (!_watchCache.contains(globalRefWatchInstance)) {
      _watchCache.add(globalRefWatchInstance);
    }
    if (!(globalRefWatchInstance as WatchCollectFactory)
        .refs
        .contains(this)) {
      (globalRefWatchInstance as WatchCollectFactory).refs.add(this);
    }
  }
  if (globalRefComputeInstance is ComputeComputeFactory) {
    if (!_computeCache.contains(globalRefComputeInstance)) {
      _computeCache.add(globalRefComputeInstance);
    }
    if (!(globalRefComputeInstance as ComputeComputeFactory)
        .refs
        .contains(this)) {
      (globalRefComputeInstance as ComputeComputeFactory).refs.add(this);
    }
  }
  if (globalRefUpdateInstance is Update) {
    // 为update收集依赖(收集在Ref.update中运行的Ref对象)
    _refresh();
  }
}