Initializable mixin
An instance that must be initialized (once) before use, after its dependencies. See the library documentation for the model, the cycles handling and the guarantees.
Implement:
- initializeDependencies: the dependencies to initialize before initialize.
- initialize: the initialization. Return InitializationResult.ok (with the post-dependencies, if any) or InitializationResult.error (or throw).
Use:
- ensureInitialized / doInitialization: initialize it (if not yet).
- executeInitialized: run code after it's initialized.
- checkInitialized: initialize it synchronously, or throw.
From a hook (initializeDependencies / initialize), other instances
can be initialized directly (e.g. other.ensureInitialized()): they are
dependencies of this one (attributed by the framework).
- Mixin applications
Properties
-
cyclicDependencies
→ List<
Initializable> -
The dependencies of the current (or last) initialization attempt that
were not waited for: they were (transitively) waiting for this instance
(a cycle), so they may still be initializing when initialize runs or
when this instance is initialized.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- initializationStatus → InitializationStatus
-
Returns the current InitializationStatus.
no setter
- isAsyncInitialization → bool
-
Returns
trueif this instance initialization was asynchronous.no setter - isInitialized → bool
-
Returns
trueif this instance is already initialized.no setter - isInitializing → bool
-
Returns
trueif this instance is in the middle of the initialization process.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
checkInitialized(
{bool allowInProgress = true}) → void - Checks if this instance is initialized, initializing it if possible.
-
doInitialization(
{Initializable? parent}) → FutureOr< InitializationResult> - Initialize this instance if is not initialized yet. Same as ensureInitialized.
-
ensureInitialized(
{Initializable? parent}) → FutureOr< InitializationResult> - Ensures that this instance is initialized.
-
ensureInitializedAsync(
{Initializable? parent}) → FutureOr< InitializationResult> - Ensures that this instance is initialized. If is not initialized yet it will force an asynchronous initialization and return a Future.
-
executeInitialized<
R> (ExecuteInitializedCallback< R> callback, {Initializable? parent}) → FutureOr<R> -
Executes the
callbackensuring that this instance was initialized. -
initialize(
) → FutureOr< InitializationResult> - Initialization implementation. Do not call it directly, use doInitialization.
-
initializeDependencies(
) → FutureOr< List< Initializable> > - Return a List of Initializable instances that need to be initialized BEFORE initialize this instance.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
interfaceMethodsNames
→ const Set<
String>