mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08: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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user