Minor readability enhancements (#1313)

* Minor readability enhancements

* Split unwieldly ApiBase

* Fix import case

* Some movements, init in root

* Simplify overloaded functions

* Some more reworks

* Hoist non-class functions

* Flatten

* Split decorate and init

* Split meta from chain

* getNext cleanup
This commit is contained in:
Jaco Greeff
2019-08-16 00:42:54 +02:00
committed by GitHub
parent 149403ec72
commit fbac330e10
15 changed files with 940 additions and 925 deletions
+6 -8
View File
@@ -2,10 +2,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BlockNumber, Header } from '@polkadot/types/interfaces';
import { BlockNumber } from '@polkadot/types/interfaces';
import { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { drr } from '../util/drr';
@@ -24,10 +24,8 @@ import { drr } from '../util/drr';
*/
export function bestNumber (api: ApiInterfaceRx): () => Observable<BlockNumber> {
return (): Observable<BlockNumber> =>
api.rpc.chain.subscribeNewHead()
.pipe(
filter((header: Header): boolean => !!header && !!header.number),
map((header: Header): BlockNumber => header.number.unwrap()),
drr()
);
api.rpc.chain.subscribeNewHead().pipe(
map((header): BlockNumber => header.number.unwrap()),
drr()
);
}