Use asyncScheduler for all derives (#2043)
This commit is contained in:
@@ -4,10 +4,9 @@
|
||||
|
||||
import { BlockNumber } from '@polkadot/types/interfaces';
|
||||
|
||||
import { Observable, combineLatest } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable, asyncScheduler, combineLatest } from 'rxjs';
|
||||
import { map, observeOn } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -30,8 +29,9 @@ export function bestNumberLag (api: ApiInterfaceRx): () => Observable<BlockNumbe
|
||||
api.derive.chain.bestNumber(),
|
||||
api.derive.chain.bestNumberFinalized()
|
||||
]).pipe(
|
||||
observeOn(asyncScheduler),
|
||||
map(([bestNumber, bestNumberFinalized]): BlockNumber =>
|
||||
createType(api.registry, 'BlockNumber', bestNumber.sub(bestNumberFinalized))
|
||||
api.registry.createType('BlockNumber', bestNumber.sub(bestNumberFinalized))
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
import { Observable, asyncScheduler, combineLatest, of } from 'rxjs';
|
||||
import { catchError, map, observeOn } from 'rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
@@ -32,6 +32,7 @@ export function getHeader (api: ApiInterfaceRx): (hash: Uint8Array | string) =>
|
||||
? api.query.session.validators.at(hash)
|
||||
: of([])
|
||||
]).pipe(
|
||||
observeOn(asyncScheduler),
|
||||
map(([header, validators]): HeaderExtended =>
|
||||
new HeaderExtended(api.registry, header, validators)
|
||||
),
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable, asyncScheduler, combineLatest, of } from 'rxjs';
|
||||
import { map, observeOn } from 'rxjs/operators';
|
||||
|
||||
import { HeaderExtended } from '../type';
|
||||
import { memo } from '../util';
|
||||
@@ -31,6 +31,7 @@ export function subscribeNewHeads (api: ApiInterfaceRx): () => Observable<Header
|
||||
? api.query.session.validators()
|
||||
: of([])
|
||||
]).pipe(
|
||||
observeOn(asyncScheduler),
|
||||
map(([header, validators]): HeaderExtended =>
|
||||
new HeaderExtended(api.registry, header, validators)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user