18 lines
575 B
TypeScript
18 lines
575 B
TypeScript
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { BlockNumber } from '@polkadot/types/interfaces';
|
|
|
|
import { Observable } from 'rxjs';
|
|
import { map } from 'rxjs/operators';
|
|
import { ApiInterfaceRx } from '@polkadot/api/types';
|
|
|
|
import { memo } from '../util';
|
|
|
|
export function eraProgress (instanceId: string, api: ApiInterfaceRx): () => Observable<BlockNumber> {
|
|
return memo(instanceId, (): Observable<BlockNumber> =>
|
|
api.derive.session.progress().pipe(
|
|
map((info) => info.eraProgress)
|
|
));
|
|
}
|