Last active
March 12, 2021 19:50
-
-
Save jhades/15279d8bfae0a1a960f38452128445f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onSelectUser(participantId:string) { | |
this.participantsService.findParticipantById(parseInt(participantId)) | |
.pipe( | |
debug(LogginLevel.DEBUG, "Loading participant from backend") | |
) | |
.subscribe( | |
participant => { | |
... | |
}, | |
console.error | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findParticipantById(participantId: number): Observable<Participant> { | |
return this.http.get(`/api/participants/${participantId}`) | |
.pipe( | |
tap( res => console.log('HTTP response:', res)), | |
map(res => res.json().payload), | |
tap(console.log) | |
) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Observable} from 'rxjs'; | |
import {tap} from 'rxjs/operators'; | |
export enum RxJsLoggingLevel { | |
TRACE, | |
DEBUG, | |
INFO, | |
ERROR | |
} | |
let rxjsLoggingLevel = RxJsLoggingLevel.INFO; | |
export function setRxJsLoggingLevel(level: RxJsLoggingLevel) { | |
rxjsLoggingLevel = level; | |
} | |
export const debug = (level: number, message:string) => | |
(source: Observable<any>) => source | |
.pipe( | |
tap(val => { | |
if (level >= rxjsLoggingLevel) { | |
console.log(message + ': ', val); | |
} | |
}) | |
); |
debug(LogginLevel.DEBUG, "Loading participant from backend")
should be
debug(RxJsLoggingLevel.DEBUG, "Loading participant from backend")
This is great, ty, just what I need to help debug an SSR issue :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Property 'debug' does not exist on type 'Observable'.
Angular 10.