I build a flutter app using RxDart
and I want to create a stream of click events. What type should this stream contain? bool
would probably work for me, but I'll always stream true
s. Is there any best practice?
You could use a Stream<void>
:
final clickEventStream = PublishSubject<void>();
When you are listening to the stream, ignore the argument using an underscore:
clickEventStream.listen((_) { ... })
To push new events to the stream, just add null
(it's a valid value for void
):
clickEventStream.add(null);
Also see https://medium.com/dartlang/dart-2-legacy-of-the-void-e7afb5f44df0