Skip to content

Commit

Permalink
Merge pull request #59 from IOT-DSA/features/timeout_ws_connection
Browse files Browse the repository at this point in the history
remove template function to make it compatible with old compiler
  • Loading branch information
rinick authored Jul 27, 2018
2 parents 3f3769a + 5e96de5 commit 80ece8e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/src/utils/promise_timeout.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
part of dslink.utils;

Future<T> awaitWithTimeout<T>(Future<T> future, int timeoutMs,
{Function onTimeout = null,
Function onSuccessAfterTimeout = null,
Function onErrorAfterTimeout = null}) {
Completer<T> completer = new Completer();
Future awaitWithTimeout(Future future, int timeoutMs,
{Function onTimeout: null,
Function onSuccessAfterTimeout: null,
Function onErrorAfterTimeout: null}) {
Completer completer = new Completer();

Timer timer = new Timer(new Duration(milliseconds: timeoutMs), () {
if (!completer.isCompleted) {
Expand All @@ -14,7 +14,7 @@ Future<T> awaitWithTimeout<T>(Future<T> future, int timeoutMs,
completer.completeError(new Exception('Future timeout before complete'));
}
});
future.then((T t) {
future.then((t) {
if (completer.isCompleted) {
if (onSuccessAfterTimeout != null) {
onSuccessAfterTimeout(t);
Expand Down

0 comments on commit 80ece8e

Please sign in to comment.