Created
May 16, 2018 15:49
-
-
Save angelnikolov/a16aa62e1e2917287e557bfc8b56fbc5 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
function awaitStream(stream$: Observable<any>, skipTime?: number) { | |
let response = null; | |
stream$.subscribe(data => { | |
response = data; | |
}); | |
if (skipTime) { | |
/** | |
* use jasmine clock to artificially manipulate time-based web apis like setTimeout and setInterval | |
* we can easily refactor this and use async/await but that means that we will have to actually wait out the time needed for every delay/mock request | |
*/ | |
jasmine.clock().tick(skipTime); | |
} | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment