Use asyncScheduler for all derives (#2043)

This commit is contained in:
Jaco Greeff
2020-03-13 12:32:42 +01:00
committed by GitHub
parent 3d0fdbd6da
commit d9dad3566a
37 changed files with 194 additions and 144 deletions
@@ -6,8 +6,8 @@ import { ApiInterfaceRx } from '@polkadot/api/types';
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
import { DerivedCollectiveProposal } from '../types';
import { combineLatest, Observable, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Observable, asyncScheduler, combineLatest, of } from 'rxjs';
import { map, observeOn, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
type Result = [Hash[], Option<Proposal>[], Option<Votes>[]];
@@ -30,6 +30,7 @@ export function proposals (api: ApiInterfaceRx, section: 'council' | 'technicalC
return (): Observable<DerivedCollectiveProposal[]> =>
api.query[section]?.proposals
? api.query[section].proposals().pipe(
observeOn(asyncScheduler),
switchMap((hashes: Hash[]): Observable<Result> =>
hashes.length
? combineLatest([
@@ -39,6 +40,7 @@ export function proposals (api: ApiInterfaceRx, section: 'council' | 'technicalC
])
: of([[], [], []])
),
observeOn(asyncScheduler),
map(parse)
)
: of([] as DerivedCollectiveProposal[]);