Skip to content

Instantly share code, notes, and snippets.

@angelnikolov
Created May 16, 2018 15:49
Show Gist options
  • Save angelnikolov/a16aa62e1e2917287e557bfc8b56fbc5 to your computer and use it in GitHub Desktop.
Save angelnikolov/a16aa62e1e2917287e557bfc8b56fbc5 to your computer and use it in GitHub Desktop.
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