BaseInstancePart<Input, T extends MvvmInstance> class
abstract
Base class for parts Parts are smallest mvvm instances They do not have state or dependencies But they can receive events and contain other parts inside Part also contain reference to parent instance and root parent instance of parts tree You can specify input type for part Parts must be annotated with instancePart annotation You also can execute requests and cancel them automatically when part will be disposed with ApiCaller.executeAndCancelOnDispose method
Also parts can execute operations in sync with SynchronizedMvvmInstance.enqueue
Example:
@instancePart
class TestInteractorPart extends BaseInstancePart<void, PostsInteractor> {
void testUpdate() {
parentInstance.updateState(parentInstance.state.copyWith(
active: false,
));
}
}
- Inheritance
-
- Object
- EventBusReceiver
- MvvmInstance<
Input?> - BaseInstancePart
- Mixed-in types
-
- SynchronizedMvvmInstance<
Input?> - ApiCaller<
Input?>
- SynchronizedMvvmInstance<
- Implementers
Constructors
Properties
-
allPartsReady
→ Observable<
bool> -
Observable indicating that all parts are connected to this instance
finalinherited
- configuration → MvvmInstanceConfiguration
-
MvvmInstanceConfiguration for this instance
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- input ↔ Input?
-
Input for this instance
latefinalinherited
- isAsync → bool
-
Getter that returns true if instance contains async parts
or require async initialization
no setterinherited
- isDisposed ↔ bool
-
Flag indicating that this instance is disposed
getter/setter pairinherited
- isInitialized ↔ bool
-
Flag indicating that this instance is fully initialized
getter/setter pairinherited
- isPaused ↔ bool
-
getter/setter pairinherited
- parentInstance ↔ T
-
Instance that created this part
getter/setter pair
-
requests
→ List<
BaseRequest> -
Collection of requests running in this instance
finalinherited
- rootParentInstance ↔ MvvmInstance?
-
Root parent instance for this part
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancelAllRequests(
) → void -
Cancels all requests in local requests collection
inherited
-
cancelPendingOperations(
) → void -
Cancels all operations in current queue
inherited
-
checkEventWasReceived(
Type event, {int? count}) → bool -
Returns true if underlying events list contains given event name
inherited
-
cleanupReceivedEvents(
) → void -
Cleans collection of received events
inherited
-
dispose(
) → void -
Base method for instance dispose
override
-
disposeSub(
) → void -
Closes underlying stream subscription for EventBus
inherited
-
enqueue(
{bool discardOnDispose = true, Duration? timeout, required Future< void> operation(), FutureOr<void> onTimeout()?}) → Future<void> -
Executes operation in sync meaning that if you wrap any code in this function
the code will be executed in place if currently there are no other operations running
otherwise function will add operation to queue and it will be executed after all previously executed operations are completed
inherited
-
executeAndCancelOnDispose<
T> (BaseRequest< T> request) → Future<Response< T> > -
Executes request and adds it in local requests collection
inherited
-
getFullPartConnectorsList(
) → List< PartConnector> -
Returns list of parts
inherited
-
initialize(
Input? input) → void -
Base method for instance initialization
inherited
-
initializeAsync(
) → Future< void> -
Base method for async instance initialization
inherited
-
initializeInstanceParts(
) → void -
Adds parts to local collection
inherited
-
initializeInstancePartsAsync(
) → Future< void> -
Adds parts to local collection
inherited
-
initializeSub(
) → void -
inherited
-
initializeWithoutConnections(
Input? input) → void -
Base method for lightweight instance initialization
inherited
-
initializeWithoutConnectionsAsync(
) → Future< void> -
Base method for lightweight async instance initialization
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on<
T> (EventBusSubscriber< T> processor, {bool reactsToPause = false, bool firesAfterResume = true}) → EventBusSubscriber -
Subscribes to event of given type
inherited
-
onAllPartReady(
) → void -
Runs for every async part when it is initialized
inherited
-
onAsyncPartReady(
Type type, int? index) → void -
Runs for every async part when it is initialized
inherited
-
pauseEventBusSubscription(
) → void -
Sets paused flag to false so events stop processing
inherited
-
resumeEventBusSubscription(
{bool sendAllEventsReceivedWhilePause = true}) → void -
Resumes events processing
inherited
-
subscribe(
) → List< EventBusSubscriber> -
Map of EventBus events and function to be executed for this events
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
useInstancePart<
InstancePartType extends BaseInstancePart< (dynamic, MvvmInstance> >{int index = 0}) → InstancePartType -
Returns initialized instance part for given type
inherited
-
waitTillEventIsReceived(
Type event, {int? count, Duration timeout = const Duration(seconds: 1)}) → Future< void> -
Waits till given event is received by this instance
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited