Skip to content

Instantly share code, notes, and snippets.

@bbrt3
Last active August 11, 2021 17:28
Show Gist options
  • Save bbrt3/449eac35d2c2bb1ea0be1986a6a15e6b to your computer and use it in GitHub Desktop.
Save bbrt3/449eac35d2c2bb1ea0be1986a6a15e6b to your computer and use it in GitHub Desktop.
TypeScript
/*
Observables are a representation of any set of values
over any amount of time.
*/
import {map, tap} from '@rxjs/operators'
getOldBookById(id: number): Observable<OldBook>{
return this.http.get<Book>(`/api/books/${id}`)
.pipe(
map(b => <OldBook>{
bookTitle: b.title,
year: b.publicationYear
}),
tap(classicBook => console.log(classicBook))
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment