* Swap internal derives to use api.derive.* * Rx vs normal decorate * Small cleanups * Res-use sessions * Cleanup types * Fix refCount lost subs * Small cleanups
21 lines
721 B
TypeScript
21 lines
721 B
TypeScript
// Copyright 2017-2019 @polkadot/api-derive 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 { BlockNumber } from '@polkadot/types/interfaces';
|
|
import { DerivedSessionInfo } from '../types';
|
|
|
|
import { Observable } from 'rxjs';
|
|
import { map } from 'rxjs/operators';
|
|
import { ApiInterfaceRx } from '@polkadot/api/types';
|
|
|
|
import { drr } from '../util';
|
|
|
|
export function eraProgress (api: ApiInterfaceRx): () => Observable<BlockNumber> {
|
|
return (): Observable<BlockNumber> =>
|
|
api.derive.session.info().pipe(
|
|
map(({ eraProgress }: DerivedSessionInfo): BlockNumber => eraProgress),
|
|
drr()
|
|
);
|
|
}
|