Skip to content

Commit

Permalink
added missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
quetool committed Oct 17, 2023
1 parent 775b055 commit 9051c01
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/apis/core/heartbit/heartbeat.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'dart:async';

import 'package:event/event.dart';
import 'package:walletconnect_flutter_v2/apis/core/heartbit/i_heartbeat.dart';

class HeartBeat implements IHeartBeat {
Timer? _heartbeatTimer;

@override
int interval;

HeartBeat({this.interval = 5});

@override
void init() {
if (_heartbeatTimer != null) return;
_heartbeatTimer = Timer.periodic(
Duration(seconds: interval),
(timer) => onPulse.broadcast(),
);
}

@override
void stop() {
_heartbeatTimer?.cancel();
_heartbeatTimer = null;
}

@override
final Event<EventArgs> onPulse = Event();
}
9 changes: 9 additions & 0 deletions lib/apis/core/heartbit/i_heartbeat.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:event/event.dart';

abstract class IHeartBeat {
abstract int interval;
abstract final Event onPulse;

void init();
void stop();
}

0 comments on commit 9051c01

Please sign in to comment.