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:
Jaco Greeff
2019-10-10 20:41:57 +02:00
committed by GitHub
parent 38529ad13c
commit bf8bed36ef
2 changed files with 8 additions and 2 deletions
+3 -1
View File
@@ -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()
);
+5 -1
View File
@@ -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()
);