There might be someone who knows why NGXS state cannot change inside of HttpClient POST request.
ctx.patchState()
Only works outside HTTP POST request.
@Action(SignIn)
signin(ctx: StateContext<AppStateModel>, { payload }: SignIn) {
// ctx.patchState({isLoggedIn:true}) this works!
return this.api$.signin(payload)
.pipe(
tap((user: User) => {
console.log(user);
ctx.patchState({ isLoggedIn: true })
})
)
.subscribe(
(user: User) => {
ctx.patchState({ isLoggedIn: true })
}
)
}