Skip to content

Commit

Permalink
feat: add RhttpCompatibleClient.createSync
Browse files Browse the repository at this point in the history
  • Loading branch information
Tienisto committed Aug 20, 2024
1 parent f3512dc commit bf82ae4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/src/client/compatible_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ class RhttpCompatibleClient with BaseClient {
return RhttpCompatibleClient._(client);
}

/// Use this method if your app is starting up to simplify the code
/// that might arise by using async/await.
///
/// Note:
/// This method crashes when configured to use HTTP/3.
/// See: https://github.com/Tienisto/rhttp/issues/10
factory RhttpCompatibleClient.createSync({
ClientSettings? settings,
List<Interceptor>? interceptors,
}) {
final client = RhttpClient.createSync(
settings: settings,
interceptors: interceptors,
);
return RhttpCompatibleClient._(client);
}

@override
Future<StreamedResponse> send(BaseRequest request) async {
try {
Expand Down
4 changes: 4 additions & 0 deletions lib/src/client/rhttp_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class RhttpClient {
/// Creates a new HTTP client synchronously.
/// Use this method if your app is starting up to simplify the code
/// that might arise by using async/await.
///
/// Note:
/// This method crashes when configured to use HTTP/3.
/// See: https://github.com/Tienisto/rhttp/issues/10
factory RhttpClient.createSync({
ClientSettings? settings,
List<Interceptor>? interceptors,
Expand Down

0 comments on commit bf82ae4

Please sign in to comment.