Skip to content

Commit

Permalink
AbortSignal.any not all.
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Dec 5, 2023
1 parent f77c897 commit 2171e3f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions impl/observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class Observable {
return new Promise((resolve, reject) => {
const ac = new AbortController();
const signal = options?.signal
? useSignalAll([ac.signal, options.signal])
? abortSignalAny([ac.signal, options.signal])
: ac.signal;
this.subscribe(
{
Expand Down Expand Up @@ -215,7 +215,7 @@ export class Observable {
let outerComplete = false;
const startInner = (value) => {
innerAC = new AbortController();
const signal = useSignalAll([innerAC.signal, destination.signal]);
const signal = abortSignalAny([innerAC.signal, destination.signal]);
let innerObservable;
try {
innerObservable = Observable.from(project(value, index++));
Expand Down Expand Up @@ -292,7 +292,7 @@ export class Observable {
return new Promise((resolve, reject) => {
const ac = new AbortController();
const signal = options?.signal
? useSignalAll([ac.signal, options.signal])
? abortSignalAny([ac.signal, options.signal])
: ac.signal;
let index = 0;
this.subscribe(
Expand Down Expand Up @@ -326,7 +326,7 @@ export class Observable {
return new Promise((resolve, reject) => {
const ac = new AbortController();
const signal = options?.signal
? useSignalAll([ac.signal, options.signal])
? abortSignalAny([ac.signal, options.signal])
: ac.signal;
let index = 0;
this.subscribe(
Expand Down Expand Up @@ -360,7 +360,7 @@ export class Observable {
return new Promise((resolve, reject) => {
const ac = new AbortController();
const signal = options?.signal
? useSignalAll([ac.signal, options.signal])
? abortSignalAny([ac.signal, options.signal])
: ac.signal;
let index = 0;
this.subscribe(
Expand Down Expand Up @@ -395,7 +395,7 @@ export class Observable {
return new Promise((resolve, reject) => {
const ac = new AbortController();
const signal = options?.signal
? useSignalAll([ac.signal, options.signal])
? abortSignalAny([ac.signal, options.signal])
: ac.signal;
let hasState = arguments.length >= 2;
let state = initialValue;
Expand Down Expand Up @@ -477,7 +477,7 @@ export class Observable {
next: (value) => {
innerAC?.abort();
innerAC = new AbortController();
const signal = useSignalAll([innerAC.signal, destination.signal]);
const signal = abortSignalAny([innerAC.signal, destination.signal]);
let innerObservable;
try {
innerObservable = Observable.from(project(value, index++));
Expand Down Expand Up @@ -644,7 +644,7 @@ class Subscriber {
constructor(signal, _observer) {
this._observer = _observer;
const ownSignal = this.#abortController.signal;
this.#signal = signal ? useSignalAll([signal, ownSignal]) : ownSignal;
this.#signal = signal ? abortSignalAny([signal, ownSignal]) : ownSignal;
}
next(value) {
if (this.isActive) {
Expand Down Expand Up @@ -719,9 +719,9 @@ class Subscriber {
}
function noop() {}

function useSignalAll(signals) {
if (typeof AbortSignal.all === 'function') {
return AbortSignal.all(signals);
function abortSignalAny(signals) {
if (typeof AbortSignal.any === 'function') {
return AbortSignal.any(signals);
} else {
const ac = new AbortController();
const handleAbort = () => {
Expand Down

0 comments on commit 2171e3f

Please sign in to comment.