takeWhile
Last updated
Last updated
takeWhile(predicate: function(value, index): boolean, inclusive?: boolean): Observable
💡 When the optional inclusive
parameter is set to true
it will also emit the first item that didn't pass the predicate.
Example 1: Take values under limit
( StackBlitz | jsBin | jsFiddle )
Example 2: (v6.4+) takeWhile with inclusive flag
( StackBlitz )
Example 3: Difference between takeWhile
and filter
( StackBlitz | jsBin | jsFiddle )
takeWhile 📰 - Official docs
takeWhile - In Depth Dev Reference
Completing a stream with takeWhile 🎥 💵 - John Linquist
📁 Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/takeWhile.ts