Publishreplay(1) for all derive functions (#557)

* Add drr

* Transform all to publishreplay(1)

* Add comment in test

* Update headers

* Update headers

* Lint
This commit is contained in:
Amaury Martiny
2019-01-09 13:03:05 +01:00
committed by Jaco Greeff
parent 07d7112f8a
commit 6781bbaa26
10 changed files with 75 additions and 17 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors
// 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.
@@ -1,4 +1,4 @@
// Copyright 2017-2019 @polkadot/ui-react-rx authors & contributors
// 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.
@@ -9,6 +9,7 @@ import ApiRx from '@polkadot/api/rx';
import { BlockNumber } from '@polkadot/types/index';
import { bestNumber } from '../chain';
import { drr } from '../util/drr';
export function sessionProgress (api: ApiRx) {
return (): Observable<BN> =>
@@ -16,11 +17,14 @@ export function sessionProgress (api: ApiRx) {
bestNumber(api)(),
api.query.session.sessionLength(),
api.query.session.lastLengthChange()
]).pipe(map(
([bestNumber, sessionLength, lastLengthChange]) =>
(bestNumber as BlockNumber || new BN(0))
.sub(lastLengthChange as BlockNumber || new BN(0))
.add(sessionLength as BlockNumber || new BN(1))
.mod(sessionLength as BlockNumber || new BN(1))
));
]).pipe(
map(
([bestNumber, sessionLength, lastLengthChange]) =>
(bestNumber as BlockNumber || new BN(0))
.sub(lastLengthChange as BlockNumber || new BN(0))
.add(sessionLength as BlockNumber || new BN(1))
.mod(sessionLength as BlockNumber || new BN(1))
),
drr()
);
}