Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combineAll执行的问题 #13

Open
httphttp opened this issue Feb 13, 2019 · 0 comments
Open

combineAll执行的问题 #13

httphttp opened this issue Feb 13, 2019 · 0 comments

Comments

@httphttp
Copy link

consoleWithTime('now')
const ho$ = interval(1000).pipe(
  take(2),
  map((x, i) => interval(1500).pipe(
    map(y => `(${i}) ${x} : ${y}`),
    take(3)
  )),
  combineAll()
)

ho$.subscribe(consoleWithTime)

执行结果

13:07:28.004 now
13:07:31.525 [ '(0) 0 : 0', '(1) 1 : 0' ] // (2 + 1.5)s
13:07:33.030 [ '(0) 0 : 1', '(1) 1 : 0' ] //**
13:07:33.031 [ '(0) 0 : 1', '(1) 1 : 1' ] //**
13:07:34.532 [ '(0) 0 : 2', '(1) 1 : 1' ] //**
13:07:34.532 [ '(0) 0 : 2', '(1) 1 : 2' ] //**

时序图


                                         0:0   0:1         0:1   0:2         0:2
                                         1:0   1:0         1:1   1:1         1:2
                                          ^     ^           ^     ^           ^
                                          |     |           |     |           |
                                          |     |           |     |           |
                                          |     |           |     |           |
                                          |     |           |     |           |
                                          +     |           +     |           +
                        +-----------------0-----------------1-----------------2------------------->
                        X                       |                 |
                        X                       |                 |
                        X                       +                 +
            +-----------------0-----------------1-----------------2------------------------------->
            X           X
            X           X
            X           X
+----- -----0----- -----1----- -----2----- -----3----- -----4----- -----5----- -----6----- ------->

注意输出里, **的那几行是同时输出的, 说明combineAll只是将最终map出来的所有流进行了combineLatest, 本例中就相当于直接combineLatest了两个interval(1500)

对比combineLatest和merge, combineAll和mergeAll的结果是不符合预期的

如果希望能按照3.5s, 4s, 5s, 5.5s, 6.5s时输出, 应该如何做?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant