Update drr equality (#1469)
* Update drr equality * null === null * Array length compare * isFunction(next.eq) * Just JSON.stringify on compare * Add distinctUntilChanged in rpc-core * prev/next -> a/b
This commit is contained in:
@@ -22,7 +22,9 @@ export const drr = (): DrrResult => <T> (source$: Observable<T>): Observable<T>
|
||||
|
||||
throw error;
|
||||
}),
|
||||
distinctUntilChanged(),
|
||||
distinctUntilChanged((a: any, b: any): boolean =>
|
||||
JSON.stringify({ value: a }) === JSON.stringify({ value: b })
|
||||
),
|
||||
publishReplay(1),
|
||||
refCount()
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { RpcInterfaceMethod } from './types';
|
||||
|
||||
import memoizee from 'memoizee';
|
||||
import { combineLatest, from, Observable, Observer, of, throwError } from 'rxjs';
|
||||
import { catchError, map, publishReplay, refCount, switchMap } from 'rxjs/operators';
|
||||
import { catchError, distinctUntilChanged, map, publishReplay, refCount, switchMap } from 'rxjs/operators';
|
||||
import interfaces from '@polkadot/jsonrpc';
|
||||
import { Option, StorageKey, Vec, createClass } from '@polkadot/types';
|
||||
import { createTypeUnsafe } from '@polkadot/types/codec';
|
||||
@@ -250,6 +250,10 @@ export default class Rpc implements RpcInterface {
|
||||
);
|
||||
};
|
||||
}).pipe(
|
||||
// Duplicated in api-derive/util/drr
|
||||
distinctUntilChanged((a: any, b: any): boolean =>
|
||||
JSON.stringify({ value: a }) === JSON.stringify({ value: b })
|
||||
),
|
||||
publishReplay(1),
|
||||
refCount()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user