AsyncEffectHandler<Effect, Msg> class abstract base

An EffectHandler implementation for handling effects asynchronously.

This abstract class provides a structured way to define asynchronous effect handling logic. Subclasses are required to implement the handle method, which processes the effect and emits messages if needed.

Usage:

To create a custom asynchronous effect handler, subclass AsyncEffectHandler and implement the handle method. The handle method will be called whenever an effect of the specified type is triggered.

Example:

final class MyAsyncEffectHandler extends AsyncEffectHandler<MyEffect, MyMsg> {
  @override
  Future<void> handle(MyEffect effect, MsgEmitter<MyMsg> emit) async {
    try {
      final result = await performAsyncOperation(effect.data);
      emit(MyMsg.success(result));
    } catch (error) {
      emit(MyMsg.failure(error));
    }
  }
}
Implemented types
Annotations
  • @experimental

Constructors

AsyncEffectHandler()
Creates an AsyncEffectHandler.
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

call(Effect effect, MsgEmitter<Msg> emit) Future<void>
Handles the effect by invoking the handle method.
override
handle(Effect effect, MsgEmitter<Msg> emit) Future<void>
Defines the asynchronous logic for processing the effect.
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