I have a SharedFlow and I want to interleave items from the non-blocking channel in a specific frequency.
(input / hot) Flow -> A, B, C, D, E, F, G, H, I, ...
Channel -> 1, 2, 3, 4, 5, ...
Output flow -> A, B, C, 1, D, E, F, 2, G, H, I, 3, ... (if channel has items)
Output flow -> A, B, C, D, E, F, G, H, I, ... (if channel has no items)
Output flow -> A, B, C, D, 1, E, F, G, 2, H, I, ... (if 1 comes just after D)
Key is that, its important to space 1, 2, 3 at regular intervals and skipped if Channel subsequently stops producing values.
I can change the channel to be a StateFlow as well. What is the idiomatic way to implement this with Kotlin flows?