The first() operator returns a new observable containing only the first element in an observable which satisfies a given condition. This operator has the following signature:
All parameters are optional:
- condition: This is the function which the value must satisfy to be retrieved
- context: This is an argument used in the given conditional function
- defaultValue: This is a value used as the default if the observable is exhausted and no item satisfies the given condition
If no condition is supplied, this operator returns the first element in the Observable. This is shown in the following example:
Rx.Observable .of(1,2,3) .first() .subscribe((i)=>console.log(i)); ...