mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(core): drop injection context assertion in production (#61560)
In other parts of the code, calls to the `assertInInjectionContext` function are guarded with `ngDevMode`. This change aligns these parts of the code with other implementations that drop such assertions in production. PR Close #61560
This commit is contained in:
parent
fa5d7ff409
commit
9416483bd3
3 changed files with 5 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ import {MonoTypeOperatorFunction, Observable} from 'rxjs';
|
|||
*/
|
||||
export function pendingUntilEvent<T>(injector?: Injector): MonoTypeOperatorFunction<T> {
|
||||
if (injector === undefined) {
|
||||
assertInInjectionContext(pendingUntilEvent);
|
||||
ngDevMode && assertInInjectionContext(pendingUntilEvent);
|
||||
injector = inject(Injector);
|
||||
}
|
||||
const taskService = injector.get(PendingTasks);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import {takeUntil} from 'rxjs/operators';
|
|||
*/
|
||||
export function takeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {
|
||||
if (!destroyRef) {
|
||||
assertInInjectionContext(takeUntilDestroyed);
|
||||
ngDevMode && assertInInjectionContext(takeUntilDestroyed);
|
||||
destroyRef = inject(DestroyRef);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,9 @@ export interface ToObservableOptions {
|
|||
* @publicApi 20.0
|
||||
*/
|
||||
export function toObservable<T>(source: Signal<T>, options?: ToObservableOptions): Observable<T> {
|
||||
!options?.injector && assertInInjectionContext(toObservable);
|
||||
if (ngDevMode && !options?.injector) {
|
||||
assertInInjectionContext(toObservable);
|
||||
}
|
||||
const injector = options?.injector ?? inject(Injector);
|
||||
const subject = new ReplaySubject<T>(1);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue