mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 06:18:45 +08:00
feat(nbstore): add indexer storage (#10953)
This commit is contained in:
@@ -52,6 +52,10 @@ export class PriorityQueue {
|
||||
return removed;
|
||||
}
|
||||
|
||||
has(id: string) {
|
||||
return this.priorityMap.has(id);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.tree.clear();
|
||||
this.priorityMap.clear();
|
||||
@@ -64,6 +68,6 @@ export class PriorityQueue {
|
||||
}
|
||||
|
||||
get length() {
|
||||
return this.tree.count;
|
||||
return this.tree.count.bind(this.tree);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Observable, type OperatorFunction } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Creates an operator that takes values from the source Observable until the given AbortSignal aborts.
|
||||
* When the signal aborts, the Observable completes.
|
||||
*
|
||||
* @param signal - The AbortSignal that will trigger completion when aborted
|
||||
* @returns An operator function that takes values until the signal aborts
|
||||
*/
|
||||
export function takeUntilAbort<T>(
|
||||
signal?: AbortSignal
|
||||
): OperatorFunction<T, T> {
|
||||
return (source$: Observable<T>) => {
|
||||
return new Observable<T>(subscriber => {
|
||||
if (signal?.aborted) {
|
||||
subscriber.error(signal.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
const abortHandler = () => {
|
||||
subscriber.error(signal?.reason);
|
||||
};
|
||||
|
||||
if (signal) {
|
||||
signal.addEventListener('abort', abortHandler);
|
||||
}
|
||||
|
||||
const subscription = source$.subscribe({
|
||||
next: value => subscriber.next(value),
|
||||
error: err => subscriber.error(err),
|
||||
complete: () => subscriber.complete(),
|
||||
});
|
||||
|
||||
return () => {
|
||||
if (signal) {
|
||||
signal.removeEventListener('abort', abortHandler);
|
||||
}
|
||||
subscription.unsubscribe();
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user