-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:deriv-com/flutter-deriv-api into …
…intercom-poc
- Loading branch information
Showing
10 changed files
with
398 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 1.4.0 | ||
|
||
* Improve the connection management strategy to reduce the time it takes to establish the WebSocket connection. | ||
|
||
## 1.0.0 | ||
|
||
* First release of the package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
lib/services/connection/api_manager/connection_config.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:flutter_deriv_api/state/connection/connection_cubit.dart'; | ||
|
||
/// [ConnectionCubit] configuration. | ||
class ConnectionConfig { | ||
/// Initializes [ConnectionConfig]. | ||
const ConnectionConfig({ | ||
this.enableDebug = false, | ||
this.printResponse = false, | ||
this.proxyAwareConnection = false, | ||
this.callTimeout, | ||
}); | ||
|
||
/// Enables debug mode. | ||
/// | ||
/// Default value is `false`. | ||
final bool enableDebug; | ||
|
||
/// Prints API response to console, only works if [enableDebug] is `true`. | ||
/// | ||
/// Default value is `false`. | ||
final bool printResponse; | ||
|
||
/// A flag to indicate if the connection is proxy aware. | ||
final bool proxyAwareConnection; | ||
|
||
/// The timeout duration for the API calls that are request/response model | ||
/// and are not subscription. The return type of these calls are [Future]. | ||
/// | ||
/// If this duration is set, and the [call] method takes more than this | ||
/// duration to complete, it will throw a [TimeoutException]. | ||
/// | ||
/// Since these are calls from a remote server and because of lack of | ||
/// connection or some other reason their future may never complete. This can | ||
/// cause the caller of the methods to wait indefinitely. To prevent this, we | ||
/// set a timeout duration for these calls. | ||
/// | ||
/// Default is `null` which means no timeout is considered. | ||
final Duration? callTimeout; | ||
} |
30 changes: 30 additions & 0 deletions
30
lib/services/connection/api_manager/timer/connection_timer.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'dart:ui'; | ||
|
||
/// A timer calls the provided [onDoAction] callback every time the | ||
/// interval elapses, allowing you to perform the action without needing to | ||
/// manually handle the timing logic. | ||
abstract class ConnectionTimer { | ||
/// Creates a [ConnectionTimer] with a specified [interval], and an | ||
/// [onDoAction] callback. | ||
ConnectionTimer({ | ||
required this.onDoAction, | ||
required this.interval, | ||
}); | ||
|
||
/// The initial interval duration between consecutive actions. | ||
final Duration interval; | ||
|
||
/// The callback function to be executed at each timer interval. | ||
final VoidCallback onDoAction; | ||
|
||
/// Returns `true` if the timer is active, otherwise `false`. | ||
bool get isActive; | ||
|
||
/// Starts the timer. | ||
/// | ||
/// The [onDoAction] callback will be triggered based on the [interval]. | ||
void start(); | ||
|
||
/// Stops the timer. | ||
void stop(); | ||
} |
Oops, something went wrong.