Open AlexDochioiu opened 1 year ago
Use Rx.defer(() => ..., reusable: true)
Hmm, I could have easily wrapped it inside a function too:
st() => Stream.fromIterable([0, 1]).asyncMap((_) async => Future.delayed(Duration(seconds: 1), () => _));
which works relatively similar to defer (expect it doesn't wait on subscription to create the stream).
That's not very relevant though. The question is, is it correct that using asyncMap
makes the stream non-reusable? Feels like a bug to me.
Because Stream.fromIterable([0, 1])
is single-subscription stream, but allows listening to it multiple time, see also https://github.com/ReactiveX/rxdart/pull/694
stream.isBroadcast
, it does not know about Stream.multi or not.I see your point. To me it still feels like unexpected behaviour. Wondering if it's worth trying to ask the people working on dart streams to expose some way of identifying MultiStream
s?
I attached a code snippet that crashes:
Crash logs:
Expected behaviour: A new stream should be created, and listened to.