call method

  1. @override
Stream<TState> call(
  1. Context<TState> context,
  2. Event event,
  3. NextMiddleware<TState> next
)
override

Implementation

@override
Stream<TState> call(
  Context<TState> context,
  Event event,
  NextMiddleware<TState> next,
) async* {
  final initialState = context.state;
  try {
    await for (final event in next(context, event)) {
      yield event;
    }
  } catch (error, stackTrace) {
    final errorEvent = onFailed(
      context,
      event,
      initialState,
      error,
      stackTrace,
    );

    await for (final event in call(context, errorEvent, next)) {
      yield event;
    }
  }
}