From ba75fede08943442d21ab752db9ce236529f5b52 Mon Sep 17 00:00:00 2001 From: Jacob Moura Date: Mon, 13 Mar 2023 15:41:46 -0300 Subject: [PATCH] InterceptorCallback and InterceptorResolver now public; --- CHANGELOG.md | 4 ++++ lib/src/presenter/interceptors.dart | 23 ++++++++++++++--------- pubspec.yaml | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b16696..f55ce88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## V1.1.6 + +- InterceptorCallback and InterceptorResolver now public; + ## V1.1.5 - Updated action CI; diff --git a/lib/src/presenter/interceptors.dart b/lib/src/presenter/interceptors.dart index 84b850d..7bcd66c 100644 --- a/lib/src/presenter/interceptors.dart +++ b/lib/src/presenter/interceptors.dart @@ -17,7 +17,7 @@ class Interceptors { /// return error; /// }); /// ``` - final request = _InterceptorCallback(); + final request = InterceptorCallback(); /// Manage response interceptors. /// @@ -32,11 +32,12 @@ class Interceptors { /// return error; /// }); /// ``` - final response = _InterceptorCallback(); + final response = InterceptorCallback(); } -class _InterceptorCallback { - final _interceptors = <_InterceptorResolver>[]; +/// Organize interceptors +class InterceptorCallback { + final _interceptors = >[]; /// Creates a new interceptor. /// [resolve]: Resolve request or response. @@ -57,12 +58,12 @@ class _InterceptorCallback { /// return error; /// }); /// ``` - _InterceptorResolver use( + InterceptorResolver use( FutureOr Function(T) resolve, { FutureOr Function(UnoError)? onError, bool Function(T)? runWhen, }) { - final interceptor = _InterceptorResolver(resolve, onError, runWhen); + final interceptor = InterceptorResolver(resolve, onError, runWhen); _interceptors.add(interceptor); return interceptor; } @@ -72,7 +73,7 @@ class _InterceptorCallback { /// final myInterceptor = uno.interceptors.request.use((request) {/*...*/}); /// uno.interceptors.request.eject(myInterceptor); /// ``` - void eject(_InterceptorResolver interceptor) => _interceptors.remove( + void eject(InterceptorResolver interceptor) => _interceptors.remove( interceptor, ); @@ -86,9 +87,11 @@ class _InterceptorCallback { return data; } + /// only test @visibleForTesting Future resolveTest(T data) => _resolve(data); + /// only test @visibleForTesting Future resolveErrorTest(UnoError error) => _resolveError(error); @@ -105,10 +108,12 @@ class _InterceptorCallback { } } -class _InterceptorResolver { +/// Resolver interceptors +class InterceptorResolver { final FutureOr Function(T) _resolve; final FutureOr Function(UnoError)? _errorResolve; final bool Function(T)? _runWhen; - _InterceptorResolver(this._resolve, this._errorResolve, this._runWhen); + /// Resolver interceptors + InterceptorResolver(this._resolve, this._errorResolve, this._runWhen); } diff --git a/pubspec.yaml b/pubspec.yaml index 19ec8ce..74c806d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: uno description: Uno is a multiplatform HTTP client, based on Axios and built following the Clean Dart approach by the Flutterando Community. -version: 1.1.5 +version: 1.1.6 homepage: https://github.com/Flutterando/uno.git environment: