removeNode method

Future<void> removeNode(
  1. Type node, {
  2. Object? tag,
})

Implementation

Future<void> removeNode(Type node, {Object? tag}) =>
    _lockFor(node, tag: tag).synchronized(() async {
      Node? n = getNode(node, tag: tag);
      if (n != null) {
        PrecisionStopwatch p = PrecisionStopwatch.start();
        nodes.removeWhere((i) => identical(i, n));
        for (VariableMirror f in n.$dependencyFields()) {
          reflect(n).getField(f.simpleName).setField(
              #$referenceCount,
              (reflect(n)
                      .getField(f.simpleName)
                      .getField(#$referenceCount)
                      .reflectee as int) -
                  1);
        }

        for (Future<void> Function(Node, NodeStorage, PrecisionStopwatch) f
            in onStopPipeline) {
          await f(n, storage, p);
        }
      }
    }).then((_) => gc());