Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve default parameter naming for Interceptor #2047

Merged
merged 4 commits into from
Nov 29, 2023
Merged

Conversation

hgraceb
Copy link
Contributor

@hgraceb hgraceb commented Nov 27, 2023

Improve default parameter naming for Interceptor.

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.
  void onRequest(
    RequestOptions options,
    RequestInterceptorHandler handler,
  ) {
    handler.next(options);
  }

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

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

New Pull Request Checklist

  • I have read the Documentation
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I'm adding
  • I have updated the documentation (if necessary)
  • I have run the tests without failures
  • I have updated the CHANGELOG.md in the corresponding package

Additional context and info (if any)

@hgraceb hgraceb requested a review from a team as a code owner November 27, 2023 05:20
Copy link
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would breaks downstream packages' CI since it'll raise warnings about the mismatch naming AFAIK. But it's easy to change the name. Any opinion? @cfug-dev

The PR still lacks of the CHANGELOG update.

dio/lib/src/interceptor.dart Outdated Show resolved Hide resolved
AlexV525

This comment was marked as duplicate.

@hgraceb
Copy link
Contributor Author

hgraceb commented Nov 27, 2023

This would breaks downstream packages' CI since it'll raise warnings about the mismatch naming AFAIK. But it's easy to change the name. Any opinion? @cfug-dev

The PR still lacks of the CHANGELOG update.

Based on my knowledge, the main purpose of parameter naming in aliases is to facilitate code completion in IDEs. It doesn't have any practical impact on other code. Matching names are only required when overriding methods, so I haven't updated the CHANGELOG.

Alternatively, should I update my understanding?

@AlexV525
Copy link
Member

Based on my knowledge, the main purpose of parameter naming in aliases is to facilitate code completion in IDEs. It doesn't have any practical impact on other code. Matching names are only required when overriding methods, so I haven't updated the CHANGELOG.

This makes sense. Thanks.

@AlexV525 AlexV525 added this pull request to the merge queue Nov 29, 2023
Merged via the queue into cfug:main with commit f4606cf Nov 29, 2023
3 checks passed
@AlexV525 AlexV525 added e: documentation Improvements or additions to documentation p: dio Targeting `dio` package labels Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e: documentation Improvements or additions to documentation p: dio Targeting `dio` package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants