本文整理匯總了TypeScript中rxjs.Observable.forkJoin方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable.forkJoin方法的具體用法?TypeScript Observable.forkJoin怎麽用?TypeScript Observable.forkJoin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rxjs.Observable
的用法示例。
在下文中一共展示了Observable.forkJoin方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getPlayerUnits
getPlayerUnits(activeAccount: string, playerUnitsLength: number) {
let indexes: any[] = [];
for (var i = 0; i < playerUnitsLength; i++) {
indexes.push(i);
}
return Observable.forkJoin(
indexes.map(index => {
return this.web3Service.callContract(
this.contractsService.UserUnitsInstance.userUnits,
[activeAccount, index, {from: activeAccount}]
).then((result) => {
if (!result ||Â result.error) {
return result;
}
let obj = {
id: result[0].toNumber(),
index: index,
quantity: result[1]
}
return obj;
})
})
);
}
示例2: _
results => {
const files = _(results)
.map(result => result.filePath)
.compact()
.uniq()
.map(filePath => readFile$(filePath)
.map(content => ({ filePath, content: content.toString().split(/(?:\n|\r\n|\r)/g) })))
.value();
return Observable.forkJoin(files);
},
示例3:
.flatMap((trans:any)=>{
var tasks$ = [];
this.transaction = trans.txn;
this.transaction.status =trans.status.confirmed;
this.transaction.block_num =trans.status.block_seq;
trans=trans.txn;
for(var i=0;i<trans.inputs.length;i++){
tasks$.push(this.getAddressOfInput(trans.inputs[i]));
}
return Observable.forkJoin(...tasks$);
});
示例4: it
it('should flush all requests on an unshared mock request', rlFakeAsync((): void => {
let mockedObservable: IMockedRequest<number> = mock.request(result => result);
Observable.forkJoin<number[]>([
mockedObservable(5),
mockedObservable(10),
]).subscribe(([result1, result2]: number[]): void => {
expect(result1).to.equal(5);
expect(result2).to.equal(10);
});
mockedObservable.flush();
}));
示例5: getAssetsRequirements
getAssetsRequirements(ids: any[]) {
return Observable.forkJoin(
ids.map(id => {
return this.web3Service.callContract(
this.contractsService.AssetsRequirementsInstance.getRequirements,
[id]
).then((result) => {
return result;
})
})
);
}
示例6: getBuildingsData
getBuildingsData(ids: any[]) {
return Observable.forkJoin(
ids.map(id => {
return this.web3Service.callContract(
this.contractsService.BuildingsDataInstance.buildings,
[id]
).then((result) => {
return result;
})
})
);
}
示例7: getBuildingsIds
getBuildingsIds(buildingsLength: number) {
let indexes = [];
for (var i = 0; i < buildingsLength; i++) {
indexes.push(i);
}
return Observable.forkJoin(
indexes.map(index => {
return this.web3Service.callContract(
this.contractsService.BuildingsDataInstance.buildingIds,
[index]
).then((result) => {
return result;
})
})
);
}
示例8: it
it('should re-report all values when subscribed a second time', () => {
const data = ['a', 'b', 'c'];
const tracker = new ProjectTracker({
getPaths() { return data; },
onDidChangePaths(cb) { return { dispose() { /* */ } }; }
});
return Observable.forkJoin(
tracker.added.take(3).toArray(),
tracker.added.delay(10).take(3).toArray(),
tracker.added.delay(5).take(3).toArray(),
).toPromise()
.then(values => {
expect(values[0]).to.deep.eq(values[1]);
expect(values[1]).to.deep.eq(values[2]);
expect(values[2]).to.deep.eq(values[0]);
});
});