Documentation / @eventkit/base / last
Function: last()
Call Signature
function last<T, D>(predicate?, defaultValue?): SingletonOperatorFunction<T, T | D>
Emits the last value emitted by the source observable that satisfies a specified condition. If no such value is found when the source observable completes, the defaultValue
is emitted if it's provided. If it isn't, a NoValuesError is thrown.
Type Parameters
Type Parameter | Default type |
---|---|
T | - |
D | T |
Parameters
Parameter | Type | Description |
---|---|---|
predicate ? | null | A function that evaluates each value emitted by the source observable. Returns true if the value satisfies the condition, false otherwise. |
defaultValue ? | D | The default value returned when no value matches the predicate. |
Returns
SingletonOperatorFunction
<T
, T
| D
>
Throws
Will throw a NoValuesError
if no value is found and no default value is provided.
Call Signature
function last<T>(predicate): SingletonOperatorFunction<T, TruthyTypesOf<T>>
Emits the last value emitted by the source observable that satisfies a specified condition. If no such value is found when the source observable completes, the defaultValue
is emitted if it's provided. If it isn't, a NoValuesError is thrown.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
predicate | BooleanConstructor | A function that evaluates each value emitted by the source observable. Returns true if the value satisfies the condition, false otherwise. |
Returns
SingletonOperatorFunction
<T
, TruthyTypesOf
<T
>>
Throws
Will throw a NoValuesError
if no value is found and no default value is provided.
Call Signature
function last<T, D>(predicate, defaultValue): SingletonOperatorFunction<T, D | TruthyTypesOf<T>>
Emits the last value emitted by the source observable that satisfies a specified condition. If no such value is found when the source observable completes, the defaultValue
is emitted if it's provided. If it isn't, a NoValuesError is thrown.
Type Parameters
Type Parameter |
---|
T |
D |
Parameters
Parameter | Type | Description |
---|---|---|
predicate | BooleanConstructor | A function that evaluates each value emitted by the source observable. Returns true if the value satisfies the condition, false otherwise. |
defaultValue | D | The default value returned when no value matches the predicate. |
Returns
SingletonOperatorFunction
<T
, D
| TruthyTypesOf
<T
>>
Throws
Will throw a NoValuesError
if no value is found and no default value is provided.
Call Signature
function last<T, S>(predicate, defaultValue?): SingletonOperatorFunction<T, S>
Emits the last value emitted by the source observable that satisfies a specified condition. If no such value is found when the source observable completes, the defaultValue
is emitted if it's provided. If it isn't, a NoValuesError is thrown.
Type Parameters
Type Parameter |
---|
T |
S |
Parameters
Parameter | Type | Description |
---|---|---|
predicate | (value , index ) => value is S | A function that evaluates each value emitted by the source observable. Returns true if the value satisfies the condition, false otherwise. |
defaultValue ? | S | The default value returned when no value matches the predicate. |
Returns
SingletonOperatorFunction
<T
, S
>
Throws
Will throw a NoValuesError
if no value is found and no default value is provided.
Call Signature
function last<T, S, D>(predicate, defaultValue): SingletonOperatorFunction<T, S | D>
Emits the last value emitted by the source observable that satisfies a specified condition. If no such value is found when the source observable completes, the defaultValue
is emitted if it's provided. If it isn't, a NoValuesError is thrown.
Type Parameters
Type Parameter |
---|
T |
S |
D |
Parameters
Parameter | Type | Description |
---|---|---|
predicate | (value , index ) => value is S | A function that evaluates each value emitted by the source observable. Returns true if the value satisfies the condition, false otherwise. |
defaultValue | D | The default value returned when no value matches the predicate. |
Returns
SingletonOperatorFunction
<T
, S
| D
>
Throws
Will throw a NoValuesError
if no value is found and no default value is provided.
Call Signature
function last<T, D>(predicate, defaultValue?): SingletonOperatorFunction<T, T | D>
Emits the last value emitted by the source observable that satisfies a specified condition. If no such value is found when the source observable completes, the defaultValue
is emitted if it's provided. If it isn't, a NoValuesError is thrown.
Type Parameters
Type Parameter | Default type |
---|---|
T | - |
D | T |
Parameters
Parameter | Type | Description |
---|---|---|
predicate | (value , index ) => boolean | A function that evaluates each value emitted by the source observable. Returns true if the value satisfies the condition, false otherwise. |
defaultValue ? | D | The default value returned when no value matches the predicate. |
Returns
SingletonOperatorFunction
<T
, T
| D
>
Throws
Will throw a NoValuesError
if no value is found and no default value is provided.