Announcement

👇Official Account👇

图片

Welcome to join the group & private message

Article first/tail QR code

Skip to content

concat

concat 操作符按顺序依次执行多个 Observable,前一个 Observable 完成后才执行下一个。

示例

typescript
import { concat, of, interval } from 'rxjs';
import { take } from 'rxjs/operators';

const stream1$ = of(1, 2, 3);
const stream2$ = of(4, 5, 6);

concat(stream1$, stream2$).subscribe(console.log);
// 输出: 1, 2, 3, 4, 5, 6

使用场景

按顺序执行多个任务,例如先登录再获取用户信息。

上次更新于: