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:
Amaury Martiny
2019-01-09 10:59:56 +01:00
committed by Jaco Greeff
parent 22123f9491
commit f6c93e48b7
17 changed files with 589 additions and 4 deletions
@@ -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)
);
}
+5
View File
@@ -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';