RX Observable.TakeWhile checks condition BEFORE each element but I need to perform the check after

前端 未结 6 2137
谎友^
谎友^ 2020-12-30 11:50

Observable.TakeWhile allows you to run a sequence as long as a condition is true (using a delegate so we can perform computations on the actual sequence objects), but it\'s

6条回答
  •  [愿得一人]
    2020-12-30 12:02

    Combo, using a new SkipUntil and TakeUntil:

    SkipUntil return source.Publish(s => s.SkipUntil(s.Where(predicate)));

    TakeUntil (inclusive) return source.Publish(s => s.TakeUntil(s.SkipUntil(predicate)));

    Full source: https://gist.github.com/GeorgeTsiokos/a4985b812c4048c428a981468a965a86

提交回复
热议问题