-
-
Save stevewithington/4b760dac156e2aa21e59bed54c560f14 to your computer and use it in GitHub Desktop.
This file contains 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)) | |
.debug("Loading participant from backend") | |
.subscribe( | |
participant => { | |
... | |
}, | |
console.error | |
); | |
} | |
This file contains 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}`) | |
.do( res => console.log('HTTP response:', res)) | |
.map(res => res.json().payload) | |
.do(console.log); | |
} | |
This file contains 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 'rxjs/add/operator/map'; | |
import 'rxjs/add/operator/mergeMap'; | |
import {Observable} from "rxjs"; | |
const debuggerOn = true; | |
Observable.prototype.debug = function (message: string) { | |
return this.do( | |
function (next) { | |
if (debuggerOn) { | |
console.log(message, next); | |
} | |
}, | |
function (err) { | |
if (debuggerOn) { | |
console.error('ERROR >>> ',message , err); | |
} | |
}, | |
function () { | |
if (debuggerOn) { | |
console.log('Completed.'); | |
} | |
} | |
); | |
}; | |
This file contains 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
declare module 'rxjs/Observable' { | |
interface Observable<T> { | |
debug: (...any) => Observable<T>; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment