brianegan/flutter_architecture_samples

flutter_architecture_samples/firestore_redux/ how can I store the StreamSubscriptions?

Open

#135 aberto em 15 de mai. de 2019

Ver no GitHub
 (6 comments) (0 reactions) (0 assignees)Dart (1.717 forks)batch import
good first issue

Métricas do repositório

Stars
 (8.920 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Hi Brian, I'm looking for a solution for storing streamsubscriptions in my middleware. How I can store the streamsubscription and cancel them if i need too?

Especially in flutter_architecture_samples/firestore_redux/lib/middleware/store_todos_middleware.dart line 66 / 67 there is a listen() which returns a subscription but it is not stored? How do you cancel the subscription?

In the E-Mail from Nilay couple days ago, there was a suggestion for using streamsubscriptions and canceling them.

http://dart-lang.github.io/linter/lints/cancel_subscriptions.html

class B {
  StreamSubscription _subscriptionB; 
  void init(Stream stream) {
    _subscriptionB = stream.listen((_) {});
  }
  void dispose(filename) {
    _subscriptionB.cancel();
  }
}

And I need in my code the fully control of the subscriptions. I would very appreciate your answer.

Cheers, :)

Guia do colaborador