import { Store } from '@ngrx/store';
import { Injectable } from '@angular/core';

import { UserStore } from '../../interfaces/user.interface';
import { UserActions } from './user.actions';

@Injectable({
  providedIn: 'root',
})
export class UserDispatchers {
  constructor(private store: Store<{ user: UserStore }>) {}

  setUser(newState: UserStore) {
    this.store.dispatch(UserActions.set_user({ user: newState }));
  }

  clearUser() {
    this.store.dispatch(UserActions.clear_user());
  }
}
