centrifugal / centrifuge-dart

Dart (Flutter) client SDK for bidirectional communication with Centrifugo and Centrifuge-based server over WebSocket
https://pub.dartlang.org/packages/centrifuge
MIT License
109 stars 34 forks source link

Close subscription streams on remove #67

Closed FZambia closed 2 years ago

FZambia commented 2 years ago

This allows exiting from async stream iterators when subscription is removed from Client's registry (i.e. when Client.removeSubscription is called):

final subscription = client.newSubscription(...);

final onPublicationEvent = () async {
  await for (var i in subscription.publication) {
    print('publication: $i');
  }
  print("subscription removed");
};
onPublicationEvent();
client.removeSubscription(subscription)

Adresses #65

FZambia commented 2 years ago

Thx for looking - I'll try to merge it this week then