builder<T extends Object?> method

T? builder<T extends Object?>(
  1. InstanceBuilder<T> builder, {
  2. String? id,
  3. Object? ref,
})
inherited

It's a ways to manage an instance, which registers a builder function and creates the instance, unless it has already done so.

When the dependency tree no longer needs it, it is completely deleted, including deregistration (deleting the builder function).

It uses less RAM than factory and singleton, but it consumes more CPU than the other modes.

Under the following conditions:

  • if not found and hasn't registered it, registers, creates and returns it.
  • if not found and has registered it, creates and returns it.
  • if found it, returns it.
  • else return null.

It's a ways to manage an instance, which registers a builder function and creates the instance, unless it has already done so.

When the dependency tree no longer needs it, it is completely deleted, including deregistration (deleting the builder function).

It uses less RAM than factory and singleton, but it consumes more CPU than the other modes.

This method is equivalent to calling:

Reactter.create<T>(
  builder,
  id: id,
  ref: ref,
  mode: DependencyMode.builder,
);

Implementation

T? builder<T extends Object?>(
  InstanceBuilder<T> builder, {
  String? id,
  Object? ref,
}) {
  return create<T>(
    builder,
    id: id,
    ref: ref,
    mode: DependencyMode.builder,
  );
}