On this page
concatWith
function
stable
operator
Emits all of the values from the source observable, then, once it completes, subscribes to each observable source provided, one at a time, emitting all of their values, and not subscribing to the next one until it completes.
concatWith<T, A extends readonly, unknown>()
Parameters
There are no parameters.
Description
concat(a$, b$, c$)
is the same as a$.pipe(concatWith(b$, c$))
.
Example
Listen for one mouse click, then listen for all mouse moves.
import { fromEvent, map, take, concatWith } from 'rxjs';
const clicks$ = fromEvent(document, 'click');
const moves$ = fromEvent(document, 'mousemove');
clicks$.pipe(
map(() => 'click'),
take(1),
concatWith(
moves$.pipe(
map(() => 'move')
)
)
)
.subscribe(x => console.log(x));
// 'click'
// 'move'
// 'move'
// 'move'
// ...
© 2015–2022 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/operators/concatWith