Rxjs-点击不是由concatMap()中的订阅触发的

时间:2019-08-16 12:49:30

标签: rxjs

我有一个主题,它映射了一个可观察对象,我在concatMap中订阅了可观察对象,但是它没有触发订阅中的tap()。

    Worksheets("PMCC-1").Copy Before:=Sheets(1)
    Sheets("PMCC-1 (2)").Select
    Sheets("PMCC-1 (2)").Name = "All-PID"

Application.ScreenUpdating = False

    Dim wsDest As Excel.Worksheet
    Dim ws As Excel.Worksheet

    Set wsDest = Sheets("All-PID")
    Set ws = ActiveSheet

For Each ws In ActiveWorkbook.Worksheets
        Select Case ws.Name
            Case Is = "All-PID", "PMCC-1"
            Case Else
            Dim iLastRowS2 As Long
            iLastRowS2 = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
            Dim iLastCellS1 As Excel.Range
            Set iLastCellS1 = wsDest.Cells(wsDest.Rows.Count, A").End(xlUp).Offset(1,0)
            ws.Range("A2", ws.Cells(iLastRowS2, "W")).Copy iLastCellS1

         End Select

Next ws

主题

this.streamA$ = this.streamService.getStream(1)
      .pipe(
        tap(data => console.log('stream data:', data))
      );

服务功能

this.images$ = this.queue.pipe(concatMap((event: Observable<string>) => {
      // when an event arrives here it is still wrapped in observable

      // subscribe isn't triggering tap()
      event.subscribe(data => {
        //console.log('inner observable subscription:', data);
      });

      // observable goes to the image$ observable, it is unwrapped by: image$ | async in template
      return event;
    }));

更新:

  getStream(time: number): Observable<string> {

    let timer$ = timer(2000);
    console.log('get stream');

    const observable = new Observable<string>(observer => {

      timer$.pipe(
        map(() => {
          observer.next('http response 1');
          observer.complete();
        })
      ).subscribe();

    });
    return observable;
  }

预订中不包含console.log,这是输出:

event.subscribe(data => {
         //console.log('inner observable subscription:', data);
      });

使用console.log,可同时打印这三行:

stream data: http response 1

1 个答案:

答案 0 :(得分:0)

如果df[rowSums(!is.na(df[nm1])) > 0,] 中有一个Observable,则无需订阅。您能按照这些方法尝试点什么吗?

    for (int i = 0; i < col0_list.Length; i++)
    {
        Console.WriteLine($"{col0_all[i]},{col1_all[i]},{col2_all[i]}");
    }