Every new change

This commit is contained in:
Luca Schwan
2020-03-25 11:05:34 +01:00
parent ff8491e75f
commit b4d041c5de
7164 changed files with 499221 additions and 135 deletions

View File

@ -0,0 +1,46 @@
import { Observable } from '../../Observable';
export function fromFetch(input, init) {
return new Observable(subscriber => {
const controller = new AbortController();
const signal = controller.signal;
let outerSignalHandler;
let abortable = true;
let unsubscribed = false;
if (init) {
if (init.signal) {
if (init.signal.aborted) {
controller.abort();
}
else {
outerSignalHandler = () => {
if (!signal.aborted) {
controller.abort();
}
};
init.signal.addEventListener('abort', outerSignalHandler);
}
}
init = Object.assign({}, init, { signal });
}
else {
init = { signal };
}
fetch(input, init).then(response => {
abortable = false;
subscriber.next(response);
subscriber.complete();
}).catch(err => {
abortable = false;
if (!unsubscribed) {
subscriber.error(err);
}
});
return () => {
unsubscribed = true;
if (abortable) {
controller.abort();
}
};
});
}
//# sourceMappingURL=fetch.js.map