Skip to content

Commit 9416483

Browse files
arturovtthePunderWoman
authored andcommitted
refactor(core): drop injection context assertion in production (angular#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 angular#61560
1 parent fa5d7ff commit 9416483

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/core/rxjs-interop/src/pending_until_event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {MonoTypeOperatorFunction, Observable} from 'rxjs';
2020
*/
2121
export function pendingUntilEvent<T>(injector?: Injector): MonoTypeOperatorFunction<T> {
2222
if (injector === undefined) {
23-
assertInInjectionContext(pendingUntilEvent);
23+
ngDevMode && assertInInjectionContext(pendingUntilEvent);
2424
injector = inject(Injector);
2525
}
2626
const taskService = injector.get(PendingTasks);

packages/core/rxjs-interop/src/take_until_destroyed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {takeUntil} from 'rxjs/operators';
2222
*/
2323
export function takeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {
2424
if (!destroyRef) {
25-
assertInInjectionContext(takeUntilDestroyed);
25+
ngDevMode && assertInInjectionContext(takeUntilDestroyed);
2626
destroyRef = inject(DestroyRef);
2727
}
2828

packages/core/rxjs-interop/src/to_observable.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export interface ToObservableOptions {
4242
* @publicApi 20.0
4343
*/
4444
export function toObservable<T>(source: Signal<T>, options?: ToObservableOptions): Observable<T> {
45-
!options?.injector && assertInInjectionContext(toObservable);
45+
if (ngDevMode && !options?.injector) {
46+
assertInInjectionContext(toObservable);
47+
}
4648
const injector = options?.injector ?? inject(Injector);
4749
const subject = new ReplaySubject<T>(1);
4850

0 commit comments

Comments
 (0)