Skip to content

Instantly share code, notes, and snippets.

@jagomf
Created September 25, 2018 09:33
Show Gist options
  • Save jagomf/9b6c0216825c2b112b5e0bad226eeead to your computer and use it in GitHub Desktop.
Save jagomf/9b6c0216825c2b112b5e0bad226eeead to your computer and use it in GitHub Desktop.
Create a Observable just like a Promise
returnObservable(): Observable<any> {
return new Observable(observer => {
if (/* whatever */) {
return observer.next(body.data);
} else {
return observer.error(body.data);
}
return { unsubscribe() {} };
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment