Created
June 3, 2018 03:55
-
-
Save qwtel/f897b46c2fa837fe7a0571f1deb8e7a6 to your computer and use it in GitHub Desktop.
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
function fetchRx(url, options) { | |
const controller = new AbortController(); | |
const { signal } = controller; | |
return Observable.create(observer => { | |
fetch(url, { signal, ...options }) | |
.then(x => observer.next(x)) | |
.catch(x => observer.error(x)) | |
.finally(() => observer.complete()) | |
return () => controller.abort(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment