Wrap all derives in memo (like rpc-core) (#1564)

This commit is contained in:
Jaco Greeff
2019-11-11 14:25:07 +01:00
committed by GitHub
parent e73c147275
commit 2875fdf2cf
40 changed files with 190 additions and 216 deletions
@@ -10,13 +10,13 @@ import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { Vec } from '@polkadot/types';
import { drr } from '../util';
import { memo } from '../util';
/**
* @description Retrieve latest list of validators
*/
export function validators (api: ApiInterfaceRx): () => Observable<DeriveStakingValidators> {
return (): Observable<DeriveStakingValidators> =>
return memo((): Observable<DeriveStakingValidators> =>
(
// Sadly the node-template is (for some obscure reason) not comprehensive, so while the derive works
// in all actual real-world deployed chains, it does create some confusion for limited template chains
@@ -29,7 +29,6 @@ export function validators (api: ApiInterfaceRx): () => Observable<DeriveStaking
).pipe(
map(([validators, currentElected]): DeriveStakingValidators => ({
currentElected, validators
})),
drr()
);
}))
));
}