rxjs

Ngrx effect parallel http call

ぐ巨炮叔叔 提交于 2021-02-17 02:07:22
问题 I have an effect that should call two different APIs (API1 and API2). Here's the effect $LoadKpiMission = createEffect(() => this.actions$.pipe( ofType<any>(EKpiActions.GetMissionsByStation), mergeMap(action => this.apiCallsService.getKpi(action.payload, '2016-04-18').pipe( map(trips => ({ type: EKpiActions.GetMissionsSuccess, payload: trips })), catchError(() => EMPTY) ) ) ) ); Here's the structure of the service getKpi(station: number, date: string) { let Kpi = `http://192.168.208.25:8998

Rxjs nested subscribe with multiple inner subscriptions

雨燕双飞 提交于 2021-02-17 01:53:20
问题 Original promise based code I'm trying to rewrite: parentPromise .then((parentResult) => { childPromise1 .then(child1Result => child1Handler(parentResult, child1Result)); childPromise2 .then(child1Result => child2Handler(parentResult, child2Result)); childPromise3 .then(child1Result => child3Handler(parentResult, child3Result)); }); I'm trying to figure a way how to avoid the nested subscriptions anti-pattern in the following scenario: parent$ .pipe(takeUntil(onDestroy$)) .subscribe(

Rxjs nested subscribe with multiple inner subscriptions

核能气质少年 提交于 2021-02-17 01:50:04
问题 Original promise based code I'm trying to rewrite: parentPromise .then((parentResult) => { childPromise1 .then(child1Result => child1Handler(parentResult, child1Result)); childPromise2 .then(child1Result => child2Handler(parentResult, child2Result)); childPromise3 .then(child1Result => child3Handler(parentResult, child3Result)); }); I'm trying to figure a way how to avoid the nested subscriptions anti-pattern in the following scenario: parent$ .pipe(takeUntil(onDestroy$)) .subscribe(

Rxjs nested subscribe with multiple inner subscriptions

拥有回忆 提交于 2021-02-17 01:49:12
问题 Original promise based code I'm trying to rewrite: parentPromise .then((parentResult) => { childPromise1 .then(child1Result => child1Handler(parentResult, child1Result)); childPromise2 .then(child1Result => child2Handler(parentResult, child2Result)); childPromise3 .then(child1Result => child3Handler(parentResult, child3Result)); }); I'm trying to figure a way how to avoid the nested subscriptions anti-pattern in the following scenario: parent$ .pipe(takeUntil(onDestroy$)) .subscribe(

Node.js - SyntaxError: Unexpected token * when import express

落花浮王杯 提交于 2021-02-16 18:28:08
问题 node: v10.16.3 npm: 6.12.0 I got a error when I import express in node. I'm using this code https://github.com/angular-university/rxjs-course, look at server/server.ts . I run server.ts with $ ts-node ./server/server.ts The related code is: import * as express from 'express'; The error is: import * as express from 'express'; ^ SyntaxError: Unexpected token * at Module._compile (internal/modules/cjs/loader.js:723:23) at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:493:23

Why use the RxJS .asObservable() getter/factory function pattern?

别说谁变了你拦得住时间么 提交于 2021-02-16 13:59:11
问题 In a lot of codebases using RxJS I seem to come across the pattern of exposing private Subjects as Observables via a getter or normal getObservable() function. My question is not why .asObservable() is used, but instead why it seems so commonly wrapped in a getter/factory function? asObservable() wrapped in getter/factory function private readonly _engineInfo$ = new Subject<EngineInfo>(); get engineInfo$() { return this._engineInfo$.asObservable(); } asObservable() as instance variable

After using ModuleMapLoaderModule, page is loading twice

a 夏天 提交于 2021-02-11 16:17:37
问题 Can someone pls help Website, page is loading twice after using ModuleMapLoaderModule, if i dont using it source code not showing in angular 7 universal Im also getting low speed at google insight and gtmatrix const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main'); try { // * NOTE :: leave this as require() since this file is built Dynamically from webpack const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main'); const { MODULE_MAP } =

After using ModuleMapLoaderModule, page is loading twice

╄→гoц情女王★ 提交于 2021-02-11 16:14:07
问题 Can someone pls help Website, page is loading twice after using ModuleMapLoaderModule, if i dont using it source code not showing in angular 7 universal Im also getting low speed at google insight and gtmatrix const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main'); try { // * NOTE :: leave this as require() since this file is built Dynamically from webpack const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main'); const { MODULE_MAP } =

Rxjs conditionally make a second http call

感情迁移 提交于 2021-02-11 15:45:10
问题 I am trying to understand rxjs (6) and how I should call conditionally make a second http post. My scenario is that: I am/have uploaded a file. I get an object identifying the current progress and a filename. If the current progress is 100 I want to make the second http post and on success of that second call return the progress and the filename If the current progress is less than 100 simply return the progress and filename My class export class BasePortalDetailsManagerService {

Rxjs conditionally make a second http call

浪子不回头ぞ 提交于 2021-02-11 15:44:28
问题 I am trying to understand rxjs (6) and how I should call conditionally make a second http post. My scenario is that: I am/have uploaded a file. I get an object identifying the current progress and a filename. If the current progress is 100 I want to make the second http post and on success of that second call return the progress and the filename If the current progress is less than 100 simply return the progress and filename My class export class BasePortalDetailsManagerService {