Add derive functions (#540)
* Make types work * Add test for derive * Skip e2e * Change description * Add some comments * Add caching * Integrate cache * Add tests * Add test * Fix types in tests * Add e2e tests * Add comments * Fix lint * Bump versions * Remove useless stuff * Address grumbles
This commit is contained in:
committed by
Jaco Greeff
parent
22123f9491
commit
f6c93e48b7
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import ApiRx from '@polkadot/api/rx';
|
||||
import { BlockNumber, Header } from '@polkadot/types/index';
|
||||
|
||||
/**
|
||||
* Get the latest block number.
|
||||
*/
|
||||
export function bestNumber (api: ApiRx) {
|
||||
return (): Observable<BlockNumber> =>
|
||||
api.rpc.chain.subscribeNewHead()
|
||||
.pipe(
|
||||
filter((header: Header) => header && !!header.blockNumber),
|
||||
map(({ blockNumber }: Header) => blockNumber)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from './bestNumber';
|
||||
Reference in New Issue
Block a user