rxjs#forkJoin TypeScript Examples
The following examples show how to use
rxjs#forkJoin.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: can-access-connect.guard.ts From xBull-Wallet with GNU Affero General Public License v3.0 | 6 votes |
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return selectPersistStateInit()
.pipe(switchMap(() => {
return forkJoin([
this.walletsQuery.selectAll().pipe(take(1)),
this.walletsAccountsQuery.selectAll().pipe(take(1))
])
.pipe(map(values => {
const canAccess = values.every(value => value.length > 0);
if (!canAccess) {
this.router.navigate(['/connect/no-wallet'], {
queryParams: route.queryParams,
});
return false;
} else {
return true;
}
}));
}));
}
Example #2
Source File: public-blockchain-adapter.service.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
private checkAllRpcProviders(timeout?: number): void {
const checkNode$ = (web3Public: EthLikeWeb3Public | SolanaWeb3Public) =>
web3Public.healthCheck(timeout).pipe(
tap(isNodeWorks => {
if (isNodeWorks) {
return;
}
if (web3Public instanceof SolanaWeb3Public) {
this.setSolanaWeb3('additional');
console.debug(`Broken Solana node has been replaced with a spare.`);
return;
}
const blockchainName = web3Public.blockchain.name;
const connector = this.connectionLinks.find(
item => item.blockchainName === blockchainName
);
if (connector?.additionalRpcLink) {
this[blockchainName].setProvider(connector.additionalRpcLink);
console.debug(
`Broken ${web3Public.blockchain.name} node has been replaced with a spare.`
);
}
})
);
forkJoin([
...ETH_LIKE_BLOCKCHAIN_NAMES.map(ethLikeBlockchainName =>
checkNode$(this[ethLikeBlockchainName])
),
checkNode$(this[BLOCKCHAIN_NAME.SOLANA])
]).subscribe(() => this._nodesChecked$.next(true));
}
Example #3
Source File: coupon.service.ts From mylog14 with GNU General Public License v3.0 | 6 votes |
getLatestBalance() {
const pool$ = this.getPoolCurrentBalance()
.pipe(
first(),
tap(balance => this.poolBalance$.next(balance)),
);
const user$ = this.getUserCurrentBalance()
.pipe(
first(),
tap(balance => this.userBalance$.next(balance)),
);
return forkJoin([pool$, user$]);
}
Example #4
Source File: assets.service.ts From nica-os with MIT License | 6 votes |
getAll() {
const keys = Object.keys(this.assetsToLoad);
const calls = [];
keys.map(async (assetKey) => {
calls.push(
this.loadAsset(assetKey)
);
});
return forkJoin(calls).pipe(
map(results => {
keys.map((key, index) => this.assetsToLoad[key] = {
...this.assetsToLoad[key],
loaded: true,
resource: results[index]
});
return this.assetsToLoad;
})
);
}
Example #5
Source File: addon.service.ts From WowUp with GNU General Public License v3.0 | 6 votes |
public getFeaturedAddons(installation: WowInstallation): Observable<AddonSearchResult[]> {
return forkJoin(
this._addonProviderService.getEnabledAddonProviders().map(async (p) => {
try {
return await p.getFeaturedAddons(installation);
} catch (e) {
console.error(`Failed to get featured addons: ${p.name}`, e);
this._searchErrorSrc.next(new GenericProviderError(e as Error, p.name));
return [];
}
})
).pipe(
map((results) => {
return _.orderBy(results.flat(1), ["downloadCount"]).reverse();
})
);
}
Example #6
Source File: contacts.component.ts From ngx-admin-dotnet-starter with MIT License | 6 votes |
constructor(private phoneService: PhoneData) {
forkJoin(
this.phoneService.getContacts(),
this.phoneService.getRecentUsers(),
)
.pipe(takeWhile(() => this.alive))
.subscribe(([contacts, recent]: [Contact[], RecentUser[]]) => {
this.contacts = contacts;
this.recent = recent;
});
}
Example #7
Source File: oracle-state.service.ts From bitcoin-s-ts with MIT License | 6 votes |
initializeState() {
console.debug('initializeState()')
return forkJoin([
this.getServerVersion(),
// this.getBuildConfig(),
this.getPublicKeyAndOracleName(),
this.getStakingAddressAndBalance(),
// this.getAllAnnouncements(), // pulling in oracle component
]).subscribe(_ => {
console.debug(' initializedState() initialized')
this.stateLoaded.next()
})
}
Example #8
Source File: account-form.component.ts From careydevelopmentcrm with MIT License | 6 votes |
private initGeos() {
let loadCountries$: Observable<Country[]> = this.geoService.fetchAllCountries();
let loadStates$: Observable<State[]> = this.geoService.fetchAllStates();
forkJoin([
loadCountries$,
loadStates$
]).subscribe(([allCountries, allStates]) => {
this.handleCountryResponse(allCountries);
this.handleStateResponse(allStates);
this.showForm();
},
(err: Error) => this.handleGeoError(err)
);
}
Example #9
Source File: external-references.ts From attack-workbench-frontend with Apache License 2.0 | 6 votes |
/**
* Parses value for references
* @param value the value to match citations within
* @param restApiConnector to connect to the REST API
* @param validateReferencesAndCitations
*/
public parseCitations(value: string, restApiConnector: RestApiConnectorService): Observable<CitationParseResult> {
let reReference = /\(Citation: (.*?)\)/gmu;
let citations = value.match(reReference);
let result = new CitationParseResult({
brokenCitations: this.validateBrokenCitations(value, [/\(Citation:([^ ].*?)\)/gmu, /\(citation:(.*?)\)/gmu])
})
if (citations) {
// build lookup api map
let api_map = {};
for (let i = 0; i < citations.length; i++) {
// Split to get source name from citation
let sourceName = citations[i].split("(Citation: ")[1].slice(0, -1);
api_map[sourceName] = this.checkAndAddReference(sourceName, restApiConnector);
}
// check/add each citation
return forkJoin(api_map).pipe(
map((api_results) => {
let citation_results = api_results as any;
for (let key of Object.keys(citation_results)) {
// was the result able to be found/added?
if (citation_results[key]) result.usedCitations.add(key)
else result.missingCitations.add(key)
}
return result;
})
)
} else {
return of(result);
}
}
Example #10
Source File: example.service.ts From halstack-angular with Apache License 2.0 | 6 votes |
getExampleFiles(files : Array<String>) {
let result = [];
files.forEach(file => {
result.push(this.getContentTab(`${this.rootExamplesPath}${file}.properties`))
});
return forkJoin(result);
}
Example #11
Source File: switch-org.page.ts From fyle-mobile-app with MIT License | 6 votes |
signOut() {
try {
forkJoin({
device: this.deviceService.getDeviceInfo(),
eou: from(this.authService.getEou()),
})
.pipe(
switchMap(({ device, eou }) =>
this.authService.logout({
device_id: device.uuid,
user_id: eou.us.id,
})
),
finalize(() => {
this.secureStorageService.clearAll();
this.storageService.clearAll();
globalCacheBusterNotifier.next();
this.userEventService.logout();
})
)
.subscribe(noop);
} catch (e) {
this.secureStorageService.clearAll();
this.storageService.clearAll();
globalCacheBusterNotifier.next();
}
}
Example #12
Source File: feature-info.service.ts From geonetwork-ui with GNU General Public License v2.0 | 6 votes |
handleFeatureInfo(): void {
const { map } = this.manager
map.on('click', (event) => {
const gfiFeaturesObservables = this.mapUtils.getGFIFeaturesObservablesFromClick(
map,
event
)
const vectorFeatures$ = of(
this.mapUtils.getVectorFeaturesFromClick(map, event)
)
const featuresObservablesArray: Observable<Feature<Geometry>[]>[] = [
...gfiFeaturesObservables,
vectorFeatures$,
]
forkJoin(...featuresObservablesArray).subscribe((featuresArrays) => {
const allFeatures = featuresArrays.reduce(
(outputFeatures, features) => [...outputFeatures, ...features],
[]
)
this.features$.emit(allFeatures)
})
})
}
Example #13
Source File: server-info.component.ts From models-web-app with Apache License 2.0 | 6 votes |
private getBackendObjects() {
console.log(
$localize`Fetching info for InferenceService ${this.namespace}/${this.serverName}`,
);
this.backend
.getInferenceService(this.namespace, this.serverName)
.subscribe(svc => {
this.updateInferenceService(svc);
const components = ['predictor', 'transformer', 'explainer'];
const obs: Observable<[string, string, ComponentOwnedObjects]>[] = [];
['predictor', 'transformer', 'explainer'].forEach(component => {
obs.push(this.getOwnedObjects(svc, component));
});
forkJoin(...obs).subscribe(objects => {
const ownedObjects = {};
for (const obj of objects) {
const component = obj[0];
ownedObjects[component] = obj[1];
}
this.ownedObjects = ownedObjects;
this.serverInfoLoaded = true;
});
});
}
Example #14
Source File: artist.component.ts From litefy with MIT License | 6 votes |
getAllInfoFromArtist() {
const requests = [];
requests.push(
this.getArtist(),
this.getArtistTopTracks(),
this.getArtistRelated(),
this.getArtistAlbums(),
);
forkJoin(requests)
.subscribe((items: any[]) => {
this.artist = items[0];
this.topTracks = items[1];
this.related = items[2];
this.albums = items[3];
window.scrollTo(0, 0);
});
}