Closed
Description
Which @ngrx/* package(s) are relevant/related to the feature request?
effects
Information
The act
operator from the @ngrx/effects
package was deprecated in v17. Instead of using act
, we recommend using core RxJS operators combined with mapResponse
from the @ngrx/operators
package for better flexibility.
Migration
BEFORE:
@Injectable()
export class AuthEffects {
readonly login$ = createEffect(() => {
return this.actions$.pipe(
ofType(LoginPageActions.loginFormSubmitted),
act({
project: ({ credentials }) =>
this.authService
.login(credentials)
.pipe(map((user) => AuthApiActions.loginSuccess({ user }))),
error: (error) => AuthApiActions.loginFailure({ error }),
operator: exhaustMap,
})
);
});
}
AFTER:
@Injectable()
export class AuthEffects {
readonly login$ = createEffect(() => {
return this.actions$.pipe(
ofType(LoginPageActions.loginFormSubmitted),
exhaustMap(({ credentials }) =>
this.authService.login(credentials).pipe(
mapResponse({
next: (user) => AuthApiActions.loginSuccess({ user }),
error: (error) => AuthApiActions.loginFailure({ error }),
})
)
)
);
});
}
I would be willing to submit a PR to fix this issue
- Yes
- No