/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/router/src/utils/first_value_from.ts
20 строк
614 B
Andrew Scott
refactor(router): Add `firstValueFrom` helper (#63485)
29 авг 2025, 22:02
29 авг 2025, 22:02
bbb46e5
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {Observable} from 'rxjs'; import {first} from 'rxjs/operators'; /** replacement for firstValueFrom in rxjs 7. We must support rxjs v6 so we cannot use it */ export function firstValueFrom<T>(source: Observable<T>): Promise<T> { return new Promise<T>((resolve, reject) => { source.pipe(first()).subscribe({ next: (value) => resolve(value), error: (err) => reject(err), }); }); }