Skip to content

@camera.ui/sdk / observable / mergeMap

Function: mergeMap()

mergeMap<T, R>(project): OperatorFn<T, R>

Defined in: observable/index.ts:388

Project each source value to a list and flatten the results into the output stream.

Type Parameters

T

T

R

R

Parameters

project

(value, index) => R[]

Function returning an array of values for each input.

Returns

OperatorFn<T, R>

Operator that flattens projected arrays into a single stream.

Example

ts
import { mergeMap } from '@camera.ui/sdk';

motionSensor.onPropertyChanged
  .pipe(mergeMap((c) => (c.property === 'detections' ? c.value as any[] : [])))
  .subscribe((det) => console.log('detection:', det));