Remove drr Observable logging (#5179)
This commit is contained in:
@@ -5,7 +5,7 @@ import type { Observable } from 'rxjs';
|
||||
|
||||
import { catchError, distinctUntilChanged, publishReplay, refCount, tap } from 'rxjs';
|
||||
|
||||
import { logger, stringify } from '@polkadot/util';
|
||||
import { stringify } from '@polkadot/util';
|
||||
|
||||
import { refCountDelay } from './refCountDelay';
|
||||
|
||||
@@ -17,18 +17,17 @@ interface Options {
|
||||
skipTimeout?: boolean;
|
||||
}
|
||||
|
||||
const l = logger('drr');
|
||||
|
||||
const CMP = (a: unknown, b: unknown): boolean =>
|
||||
stringify({ t: a }) === stringify({ t: b });
|
||||
|
||||
const ERR = (error: Error): Observable<never> => {
|
||||
l.error(error.message);
|
||||
function CMP (a: unknown, b: unknown): boolean {
|
||||
return stringify({ t: a }) === stringify({ t: b });
|
||||
}
|
||||
|
||||
function ERR (error: Error): Observable<never> {
|
||||
throw error;
|
||||
};
|
||||
}
|
||||
|
||||
const NOOP = (): void => undefined;
|
||||
function NOOP (): void {
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand for distinctUntilChanged(), publishReplay(1) and refCount().
|
||||
@@ -36,14 +35,16 @@ const NOOP = (): void => undefined;
|
||||
* @ignore
|
||||
* @internal
|
||||
*/
|
||||
export const drr = ({ delay, skipChange = false, skipTimeout = false }: Options = {}): DrrResult => <T> (source$: Observable<T>): Observable<T> =>
|
||||
source$.pipe(
|
||||
catchError(ERR),
|
||||
skipChange
|
||||
? tap(NOOP)
|
||||
: distinctUntilChanged<T>(CMP),
|
||||
publishReplay(1),
|
||||
skipTimeout
|
||||
? refCount()
|
||||
: refCountDelay(delay)
|
||||
);
|
||||
export function drr ({ delay, skipChange = false, skipTimeout = false }: Options = {}): DrrResult {
|
||||
return <T> (source$: Observable<T>): Observable<T> =>
|
||||
source$.pipe(
|
||||
catchError(ERR),
|
||||
skipChange
|
||||
? tap(NOOP)
|
||||
: distinctUntilChanged<T>(CMP),
|
||||
publishReplay(1),
|
||||
skipTimeout
|
||||
? refCount()
|
||||
: refCountDelay(delay)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user