代码之家  ›  专栏  ›  技术社区  ›  FussinHussin

如何在NGRX效应中对多个流使用SSE

  •  0
  • FussinHussin  · 技术社区  · 6 年前

    this post

    (一)

    (二)

    这是我当前的进程和伪代码:

    @Effect()
        getTraceData = this.actions$
            .ofType(appActions.GET_PLOT_DATA)
            .pipe(
                switchMap((action$: appActions.GetPlotDataAction) => {
                        // instead of http post, return two event sources
                        // new EventSource('/data1') + new EventSource('/data2')
                        return this.http.post(
                            `http://${this.url}/low-res-data`,
                            action$.payload.getJson(),
                            { responseType: 'json', observe: 'body', headers: this.headers });
                }),
                // not sure if I should use forkJoin or MergeMap
                // to make the data = { data1, data2}
                map((plotData) => {
                    return {
                            type: appActions.LOAD_PLOT_DATA_SUCCESS,
                            payload: plotData
                    }
                }),
            )
    
    0 回复  |  直到 6 年前