stream_transform icon indicating copy to clipboard operation
stream_transform copied to clipboard

Enforcing a minimum wait time between emissions without delaying the first

Open Lootwig opened this issue 7 months ago • 0 comments

Given a stream with events at t = 0, 1, 2, 5, 6, is there a way to transform this into a stream where each event adds a 2 second hold until the next event is emitted?

I tried .asyncMapBuffer((events) => Future.delayed(const Duration(seconds: 2), () => events.last)), but that adds an unwanted 2 second delay to the very first event, too.

Lootwig avatar Jan 09 '24 16:01 Lootwig