Created
January 9, 2019 05:12
-
-
Save caroso1222/a64e1b317f074815305a7e17f93d7404 to your computer and use it in GitHub Desktop.
rxjs-log-step-final.ts
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
export function log() { | |
return function logFn<T>(source: Observable<T>) { | |
const output = new Observable<T>(observer => { | |
const subscription = source.subscribe( | |
val => { | |
console.log(val); | |
observer.next(val); | |
}, | |
err => { | |
console.error(err); | |
observer.error(err); | |
}, | |
() => { | |
console.log('%ccomplete', 'color: green'); | |
observer.complete(); | |
} | |
); | |
return subscription; | |
}); | |
return output; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment