blob: 9a03455be7899ffd077c275e190ee7b951439e9c [file] [log] [blame]
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {Observable} from 'rxjs';
import {distinctUntilChanged, map, shareReplay} from 'rxjs/operators';
import {deepEqual} from './deep-util';
export function select<A, B>(obs$: Observable<A>, mapper: (_: A) => B) {
return obs$.pipe(
map(mapper),
distinctUntilChanged(deepEqual),
shareReplay(1)
);
}