https://i.sstatic.net/uD6Vp.png
The block of code responsible for triggering the specified action
constructor(auth: AuthService, private store: Store) {
this.userAuth = auth.signedIn.subscribe({ next: (user) => {
this.user = user;
this.store.dispatch(new SetUser(user));
}});
}
The definition of the actions being carried out
import firebase from 'firebase/app';
export class SetUser {
static readonly type = '[firebase.User | null] Add';
constructor(public payload: firebase.User | null) {}
}
Here's how my store is implemented:
@Action(SetUser)
add({ patchState }: StateContext<UserStateModel>, { payload }: SetUser): void {
patchState({
user: payload
});
}
@State<UserStateModel>({
name: 'user',
defaults: {
user: null
}
})