Created
September 25, 2018 09:33
-
-
Save jagomf/9b6c0216825c2b112b5e0bad226eeead to your computer and use it in GitHub Desktop.
Create a Observable just like a Promise
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
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