DefaultObjectProvider<T> class

Default implementation of ObjectProvider in Jetleaf.

This class is responsible for retrieving pods (objects) from the PodFactory and exposing them through a consistent provider interface.

It supports both direct retrieval (via get) and streaming (via stream).

Example

final provider = DefaultObjectProvider<MyService>(
  'myServicePod',
  factory,
  [ObjectHolder(MyService())],
);

// Retrieve an object
final holder = await provider.get();
print(holder.object);

// Stream objects
await for (final obj in provider.stream()) {
  print('Received: ${obj.object}');
}

This is part of Jetleaf – a framework which developers can use to build web applications.

Inheritance
Annotations
  • @Generic.new(DefaultObjectProvider)

Constructors

DefaultObjectProvider(String _podName, PodFactory _factory, List<ObjectHolder<T>> objects)
Default implementation of ObjectProvider in Jetleaf.

Properties

hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true if no objects are available.
no setterinherited
isNotEmpty bool
Returns true if at least one object is available.
no setterinherited
objects List<ObjectHolder<T>>
The list of pre-registered ObjectHolder instances.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

chain<R>(ObjectFactory<R> nextFactory(T)) Future<ObjectFactory<R>>
Creates a new ObjectFactory that uses this factory's output as input to another factory.
inherited
copyWith({ObjectFactoryFunction<T>? creator}) ObjectFactory<T>
Creates a copy of this ObjectFactory with a new creator function.
inherited
createMultiple(int count) Future<List<T>>
Creates multiple instances of type T in a single call.
inherited
get([List<ArgumentValue>? args]) FutureOr<ObjectHolder<T>>
Retrieves the single object instance or throws if none or more than one found.
override
getIfAvailable([Supplier<ObjectHolder<T>>? supplier]) Future<ObjectHolder<T>?>
Retrieves the object if available, or returns null if none exist.
inherited
getIfUnique([Supplier<ObjectHolder<T>>? supplier]) Future<ObjectHolder<T>?>
Retrieves the object only if exactly one instance exists, or returns null.
inherited
ifAvailable(Consumer<ObjectHolder<T>> consumer) Future<void>
Executes consumer if the object is available.
inherited
ifUnique(Consumer<ObjectHolder<T>> consumer) Future<void>
Executes consumer only if exactly one instance is available.
inherited
iterator() Iterator<T>
Returns an iterator over all available objects.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stream() → GenericStream<ObjectHolder<T>>
Returns a GenericStream of all available objects.
override
toList() List<T>
Returns a list of all available objects.
inherited
toString() String
Returns a string representation of this ObjectFactory.
inherited
withSideEffect(void sideEffect(T)) Future<ObjectFactory<T>>
Creates a new factory that performs a side effect after object creation.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited