Skip to content

Commit

Permalink
Use single method
Browse files Browse the repository at this point in the history
  • Loading branch information
devsdocs committed Jun 21, 2024
1 parent dfcd224 commit 3924e05
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/src/televerse/bot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,7 @@ class Bot {
fetcher.onUpdate().listen(
_onUpdate,
onDone: () async {
_onStop.call();
await _onStopAsync.call();
await _onStop.call();
},
);
try {
Expand Down Expand Up @@ -1481,25 +1480,15 @@ class Bot {
}

/// On Stop Handler
void Function() _onStop = () {};

/// On Stop Async Handler
Future<void> Function() _onStopAsync = () async {};
FutureOr<void> Function() _onStop = () {};

/// Registers a callback when the the bot is stopped.
///
/// This can be used to clean up resources.
void onStop(void Function() callback) {
void onStop(FutureOr<void> Function() callback) {
_onStop = callback;
}

/// Registers an async callback when the the bot is stopped.
///
/// This can be used to clean up resources.
Future<void> onStopAsync(Future<void> Function() asyncCallback) async {
_onStopAsync = asyncCallback;
}

/// Internal method to handle sub message handlers
void _internalSubMessageHandler(
Handler callback,
Expand Down

0 comments on commit 3924e05

Please sign in to comment.