Watches what a scope tree does.
Every method does nothing by default, so an observer overrides only what it
cares about and a new event added later does not break it. Pass observers
to CobaltScope.root or CobaltApplication.start; a child scope inherits
its parent's observers.
Callbacks are invoked synchronously, in the middle of the work they describe. Keep them cheap, and do not resolve, register or dispose from inside one — which is why they receive CobaltScopeRef and CobaltKey rather than live objects.
An exception thrown from a callback is caught and ignored: watching must not be able to break the graph it is watching.
Resolution itself is not reported. A cache hit is the hot path, and an
event per get would be noise; what is worth seeing is an instance being
built, which onInstanceCreated covers.
Constructors
- CobaltObserver()
-
Creates an observer.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onBootstrapStepCompleted(
String step, Duration took) → void - A bootstrap step finished.
-
onBootstrapStepFailed(
String step, Object error, StackTrace stackTrace) → void - A bootstrap step threw. Startup is aborted and earlier steps released.
-
onBootstrapStepReleaseFailed(
String step, Object error, StackTrace stackTrace) → void - Releasing an already-completed step failed while rolling startup back.
-
onBootstrapStepStarted(
String step) → void - A bootstrap step is about to run.
-
onInstanceBuilt(
CobaltScopeRef scope, CobaltKey key, {required CobaltRegistrationKind kind, required bool retained, required Duration took}) → void -
The instance onInstanceCreated just reported took
tookto build. -
onInstanceCreated(
CobaltScopeRef scope, CobaltKey key, {required CobaltRegistrationKind kind, required bool retained}) → void - An instance was constructed.
-
onInstanceDisposed(
CobaltScopeRef scope, String label) → void -
An owned instance was disposed without error.
labelis its type. -
onInstanceSelfTime(
CobaltScopeRef scope, CobaltKey key, Duration self) → void -
How much of the build onInstanceBuilt reports next was spent on
keyitself: its time without the builds it waited on, whether it resolved them in its constructor, through@injectedfields or in an async factory. -
onPromiseBroken(
CobaltScopeRef scope, CobaltKey key) → void -
keywas promised toscopewithCobaltScope.promise, and the builder that ran against it returned without registering it. -
onRegistrationOverridden(
CobaltScopeRef scope, CobaltKey key) → void -
The registration of
keywas skipped, because an override handed toscopealready holds it. -
onScopeDisposed(
CobaltScopeRef scope, Duration took, List< CobaltDisposeFailure> failures) → void -
Teardown finished, always —
failuresis what it could not release. -
onScopeDisposeStarted(
CobaltScopeRef scope) → void - Teardown began. The scope is already unusable at this point.
-
onScopeInitCompleted(
CobaltScopeRef scope, Duration took) → void - Every async singleton finished building.
-
onScopeInitFailed(
CobaltScopeRef scope, Object error, StackTrace stackTrace) → void -
init()failed. The error is also thrown to whoever calledinit(). -
onScopeInitStarted(
CobaltScopeRef scope, int levels) → void -
init()started, withlevelslevels of async singletons to build. -
onScopeParentMismatch(
CobaltScopeRef scope, {required Type marker, required Type declaredParent}) → void -
scopewas built for the@CobaltChildScopeclassmarker, which is declared to open underdeclaredParent, and no scope above it was built for that class. -
onScopePushed(
CobaltScopeRef scope) → void - A child scope was pushed.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited