of<T> static method

ManifoldProvider<T> of<T>(
  1. BehaviorSubject<T> subject, {
  2. bool readOnly = false,
})

Implementation

static ManifoldProvider<T> of<T>(
  BehaviorSubject<T> subject, {
  bool readOnly = false,
}) {
  $AClass<T>? mirror = ArtifactAccessor.blindReflect<T>();

  if (mirror == null) {
    Future.delayed(
      1.seconds,
      () => warn(
        "No artifact accessor found for type $T. Forget @manifold or to run the build runner?\nYou also may need to make an artifact object or do a to.json or something before using manifold initially to trigger artifact's initialization.",
      ),
    );

    info("Registered artifact accessors: ${ArtifactAccessor.all.length}");
    info(
      ArtifactAccessor.all.expand((i) => i.artifactMirror.keys).join(", "),
    );

    throw Exception(
      "No artifact accessor found for type $T. Forget @manifold or to run the build runner?",
    );
  }

  if (!subject.hasValue) {
    subject.add(mirror.construct());
  }

  return ManifoldProvider<T>(subject, mirror, readOnly: readOnly);
}