Explain the different types of Streams?

Technology CommunityCategory: FlutterExplain the different types of Streams?
VietMX Staff asked 3 years ago

There are two kinds of streams. 1. Single subscription streams – The most common kind of stream. – It contains a sequence of events that are parts of a larger whole. Events need to be delivered in the correct order and without missing any of them. – This is the kind of stream you get when you read a file or receive a web request. – Such a stream can only be listened to once. Listening again later could mean missing out on initial events, and then the rest of the stream makes no sense. – When you start listening, the data will be fetched and provided in chunks.

  1. Broadcast streams
    • It intended for individual messages that can be handled one at a time. This kind of stream can be used for mouse events in a browser, for example.
    • You can start listening to such a stream at any time, and you get the events that are fired while you listen.
    • More than one listener can listen at the same time, and you can listen again later after canceling a previous subscription.