Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class StreamSub<T> implements Subscription {
constructor(private _stream: Stream<T>, private _listener: InternalListener<T>) { }

unsubscribe(): void {
this._stream._remove(this._listener);
this._stream._remove(this._listener, true);
}
}

Expand Down Expand Up @@ -1151,7 +1151,7 @@ export class Stream<T> implements InternalListener<T> {
}
}

_remove(il: InternalListener<T>): void {
_remove(il: InternalListener<T>, async: boolean = false): void {
const ta = this._target;
if (ta) return ta._remove(il);
const a = this._ils;
Expand All @@ -1160,7 +1160,11 @@ export class Stream<T> implements InternalListener<T> {
a.splice(i, 1);
if (this._prod !== NO && a.length <= 0) {
this._err = NO;
this._stopID = setTimeout(() => this._stopNow());
if (async) {
this._stopID = setTimeout(() => this._stopNow());
} else {
this._stopNow();
}
} else if (a.length === 1) {
this._pruneCycles();
}
Expand Down Expand Up @@ -1216,7 +1220,7 @@ export class Stream<T> implements InternalListener<T> {
* @param {Listener<T>} listener
*/
removeListener(listener: Partial<Listener<T>>): void {
this._remove(listener as InternalListener<T>);
this._remove(listener as InternalListener<T>, true);
}

/**
Expand Down