Skip to content

Commit a787afb

Browse files
committed
refactor(state): use inject instead of constructor-di in RxEffects
1 parent bbb47d0 commit a787afb

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

libs/state/effects/src/lib/effects.service.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
DestroyRef,
3-
ErrorHandler,
4-
inject,
5-
Injectable,
6-
Optional,
7-
} from '@angular/core';
1+
import { DestroyRef, ErrorHandler, inject, Injectable } from '@angular/core';
82
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
93
import {
104
EMPTY,
@@ -75,6 +69,7 @@ import { toHook } from './utils';
7569
export class RxEffects implements OnDestroy$ {
7670
private static nextId = 0;
7771
private readonly destroyRef = inject(DestroyRef);
72+
private readonly errorHandler = inject(ErrorHandler, { optional: true });
7873
readonly _hooks$ = new Subject<DestroyProp>();
7974
private readonly observables$ = new Subject<Observable<unknown>>();
8075
// we have to use publish here to make it hot (composition happens without subscriber)
@@ -83,10 +78,7 @@ export class RxEffects implements OnDestroy$ {
8378
onDestroy$: Observable<boolean> = this._hooks$.pipe(toHook('destroy'));
8479
private readonly destroyers: Record<number, Subject<void>> = {};
8580

86-
constructor(
87-
@Optional()
88-
private readonly errorHandler: ErrorHandler | null,
89-
) {
81+
constructor() {
9082
this.destroyRef.onDestroy(() => {
9183
this._hooks$.next({ destroy: true });
9284
this.subscription.unsubscribe();

0 commit comments

Comments
 (0)