fromStream<Model, Msg, S> static method
SubItem<Model, Msg>
fromStream<Model, Msg, S>(
- SubscriptionId id,
- Stream<
S> stream, - Msg? streamObjectToMsg(
- S
Creates a subscription from a stream, transforming the stream objects to messages.
Implementation
static SubItem<Model, Msg> fromStream<Model, Msg, S>(SubscriptionId id,
Stream<S> stream, Msg? Function(S) streamObjectToMsg) =>
(
id,
(handler) => stream.listen((s) {
if (streamObjectToMsg(s) case Msg msg) {
handler(msg);
}
}).cancel
);