Skip to content

Commit 7860a2e

Browse files
committed
Implemented the ability to subscribe to the main thread from the base class twice or more times.
1 parent 58152d3 commit 7860a2e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/src/vkdart/fetch/abstract_update_fetcher.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ abstract class AbstractUpdateFetcher {
77
final StreamController<VkDartUpdate> _updatesController;
88

99
/// constructor
10-
AbstractUpdateFetcher() : _updatesController = StreamController();
10+
AbstractUpdateFetcher() : _updatesController = StreamController.broadcast();
1111

1212
/// add [update] to updates stream.
1313
void emitUpdate(VkDartUpdate update) => _updatesController.add(update);

lib/src/vkdart/vkdart.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ class VkDart extends Vkontakte {
8686

8787
/// Start fetcher
8888
Future<void> start() async {
89-
fetcher.onUpdate().listen(_event.emitUpdate);
89+
onUpdate().listen(_event.emitUpdate);
9090
return fetcher.start();
9191
}
9292

9393
/// Stop fetcher
9494
Future<void> stop() => fetcher.stop();
9595

96+
/// Listen for events.
97+
Stream<VkDartUpdate> onUpdate() => fetcher.onUpdate();
98+
9699
/// Listen for `message_new`, `message_edit`, `message_reply` events.
97100
Stream<VkDartMessageUpdate> onMessage() =>
98101
_event.onMessage().map((event) => VkDartMessageUpdate(this, event));

0 commit comments

Comments
 (0)