first
Last updated
Last updated
first(predicate: function, select: function)
π‘ The counterpart to first is last!
π‘ First
will deliver an EmptyError to the Observer's error callback if the Observable completes before any next notification was sent. If you don't want this behavior, use take(1)
instead.
( example tests )
Example 1: First value from sequence
( StackBlitz | jsBin | jsFiddle )
Example 2: First value to pass predicate
( StackBlitz | jsBin | jsFiddle )
Example 3: Utilizing default value
( StackBlitz | jsBin | jsFiddle )
first π° - Official docs
Filtering operator: take, first, skip π₯ π΅ - AndrΓ© Staltz
π Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/first.ts