canonical / nm.dart

Native Dart client library to access NetworkManager on Linux.
https://pub.dev/packages/nm
Mozilla Public License 2.0
29 stars 11 forks source link

Are streams broadcast? #48

Closed Taha-Firoz closed 3 years ago

Taha-Firoz commented 3 years ago

I had a similar problem with generated streams from dbus-dart where streams weren't broadcast by default and would throw an error if listened to more than once. Does this problem exist for nm too, I was going through the source and didn't see any conversion to asBroadcastStream. This can be a use case when certain streams should only be listened to when a specific widget is visible which is destroyed after.

jpnurmi commented 3 years ago

All stream controllers are using the StreamController.broadcast constructor:

lib/src/network_manager_client.dart:1935:  final propertiesChangedStreamController =
lib/src/network_manager_client.dart:1936:      StreamController<List<String>>.broadcast();
lib/src/network_manager_client.dart:2181:  final _deviceAddedStreamController =
lib/src/network_manager_client.dart:2182:      StreamController<NetworkManagerDevice>.broadcast();
lib/src/network_manager_client.dart:2183:  final _deviceRemovedStreamController =
lib/src/network_manager_client.dart:2184:      StreamController<NetworkManagerDevice>.broadcast();
lib/src/network_manager_client.dart:2185:  final _activeConnectionAddedStreamController =
lib/src/network_manager_client.dart:2186:      StreamController<NetworkManagerActiveConnection>.broadcast();
lib/src/network_manager_client.dart:2187:  final _activeConnectionRemovedStreamController =
lib/src/network_manager_client.dart:2188:      StreamController<NetworkManagerActiveConnection>.broadcast();
Taha-Firoz commented 3 years ago

Thank you