Menu

Post image 1
Post image 2
1 / 2
0

The Stream class in Dart

DEV Community: dart·Mathieu K·3 days ago
#8b8p3hRc
#dev#stream#fullscreen#dart#print#article
Reading 0:00
15s threshold

We have seen the Future class in a previous publication, we can now start learning a bit more about the Stream  class. In fact, the Future.asStream()  method was already there to show a quick example how work a Stream . What a difference with a Future ? Well, a Future is dealing with only one event, a Stream  deals with a sequence of events. This sequence of events can be created using yield* . In this case, the function needs to be marked with async* , and will return a Stream<E> where E is the event type. In short, you can see these objects like an Iterable  with side effects. A source of asynchronous data events. -- Dart Language Documentation, Stream class Like for the Future class, I will try to take few interesting methods/constructors from the Stream class and give some example with use cases. Single vs Broadcast Streams A single-subscription Stream is a finite sequence of events, having a beginning and an ending. Only one listener can be configured this kind of objects.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More