Skip to content

Commit

Permalink
📇 Setting stream controllers in init
Browse files Browse the repository at this point in the history
  • Loading branch information
HeySreelal committed Sep 12, 2024
1 parent 7798c5c commit f20f609
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/src/televerse/bot/bot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@ class Bot<CTX extends Context> {
} catch (err, st) {
_handleTheGetMeError(err, st);
}
// Set stream controllers
if (fetcher._updateStreamController == null ||
fetcher._updateStreamController?.isClosed == true) {
fetcher._updateStreamController = StreamController<Update>.broadcast();
}
if (fetcher._updatesStreamController == null ||
fetcher._updatesStreamController?.isClosed == true) {
fetcher._updatesStreamController =
StreamController<List<Update>>.broadcast();
}
// Set instance variable
_instance = this;
}
Expand Down Expand Up @@ -598,7 +609,6 @@ class Bot<CTX extends Context> {
await _initializeBot();
}
fetcher._updateStreamController = StreamController<Update>.broadcast();
fetcher._updateSubscription = fetcher.onUpdate().listen(
_onUpdate,
onDone: _onStop,
Expand Down

0 comments on commit f20f609

Please sign in to comment.