internal static async IAsyncEnumerable <T> Flow_Internal(FlowProducerBase <T> self, Predicate <T> stop = null, int maxDroplets = 0) { while (self.IsFlowStarted) { var ret = await self.Drip(); if (self.IsOpen) { yield return(ret); } if (!self.IsOpen || --maxDroplets == 0 || (stop != null && stop(ret))) { break; } } }
internal static IAsyncEnumerator <T> Flow_Internal(FlowProducerBase <T> self, Predicate <T> stop = null, int maxDroplets = 0) { return(new AsyncEnumerator <T>(async yield => { while (self.IsFlowStarted) { T ret = await self.Drip(); if (self.IsOpen) { await yield.ReturnAsync(ret); } if (!self.IsOpen || --maxDroplets == 0 || (stop != null && stop(ret))) { break; } } })); }