The lastValueFrom
function from the rxjs
library is used to get the last value emitted by an observable, after it completes. Here's an example of how to use this function in TypeScript:
index.ts252 chars9 lines
Note that lastValueFrom
returns a promise, so it can only be used inside an async function. Also, if the observable never completes or emits any values, lastValueFrom
will hang forever. So be sure to handle error cases appropriately.
gistlibby LogSnag