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