ServiceMixin mixin

Adds a sequenced lifecycle (init → pause/resume* → dispose) to any class.

Subclasses provide listeners via the provideX hooks; the init, pause, resume and dispose driver methods invoke them in order through a TaskSequencer so concurrent lifecycle calls serialize cleanly.

Mixin applications

Properties

didEverInitAndSuccessfully bool
true once init has completed successfully at least once for this service instance. Stays true even after a subsequent error or dispose.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state ServiceState
The current state of the service.
no setter

Methods

dispose({bool eagerError = false}) Resolvable<Unit>
Drives the service into ServiceState.DISPOSE_SUCCESS by running listeners from provideDisposeListeners.
init({bool eagerError = true}) Resolvable<Unit>
Drives the service from ServiceState.NOT_INITIALIZED to ServiceState.RUN_SUCCESS by running every listener from provideInitListeners sequentially.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause({bool eagerError = false}) Resolvable<Unit>
Transitions the service into ServiceState.PAUSE_SUCCESS by running listeners from providePauseListeners.
provideDisposeListeners(void _) TServiceResolvables<Unit>
Subclasses return the listeners to run when dispose is called. Mixins must call super.provideDisposeListeners(null) and prepend/append their own listeners (typically prepending teardown ahead of super's base cleanup).
provideInitListeners(void _) TServiceResolvables<Unit>
Subclasses return the listeners to run when init is called. Mixins must call super.provideInitListeners(null) and prepend/append their own listeners.
providePauseListeners(void _) TServiceResolvables<Unit>
Subclasses return the listeners to run when pause is called. Mixins must call super.providePauseListeners(null) and prepend/append their own listeners.
provideResumeListeners(void _) TServiceResolvables<Unit>
Subclasses return the listeners to run when resume is called. Mixins must call super.provideResumeListeners(null) and prepend/append their own listeners.
resume({bool eagerError = false}) Resolvable<Unit>
Transitions the service into ServiceState.RESUME_SUCCESS by running listeners from provideResumeListeners.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

unregister(Result<ServiceMixin> serviceResult) Resolvable<Unit>
A static hook for the DI system to properly dispose of the service upon unregistering.