Skip to content

Update Interceptor return types for 6.0.0 #2141

Open
@kuhnroyal

Description

@kuhnroyal

Request Statement

Following #2139 we should update the Interceptor function return types.
But this is a breaking change so we can only do this for dio 6.0.0.

Solution Brainstorm

class Interceptor {
  /// The constructor only helps sub-classes to inherit from.
  /// Do not use it directly.
  const Interceptor();

  /// Called when the request is about to be sent.
  FutureOr<void> onRequest(
    RequestOptions options,
    RequestInterceptorHandler handler,
  ) {
    handler.next(options);
  }

  /// Called when the response is about to be resolved.
  FutureOr<void> onResponse(
    Response response,
    ResponseInterceptorHandler handler,
  ) {
    handler.next(response);
  }

  /// Called when an exception was occurred during the request.
  FutureOr<void> onError(
    DioException err,
    ErrorInterceptorHandler handler,
  ) {
    handler.next(err);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    p: dioTargeting `dio` packages: featureThis issue indicates a feature request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions