You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

35 lines
1.0 KiB

  1. import { Component, OnInit } from "@angular/core";
  2. import { Store } from "@ngrx/store";
  3. import { Observable } from "rxjs/Observable";
  4. import { DataStorageService } from "../../shared/data-storage.service";
  5. import * as fromApp from '../../ngrx/app.reducers';
  6. import * as fromAuth from '../../auth/ngrx/auth.reducers';
  7. import * as AuthActions from '../../auth/ngrx/auth.actions';
  8. import * as RecipeActions from '../../recipes/ngrx/recipe.actions';
  9. @Component({
  10. selector: 'app-header',
  11. templateUrl: './header.component.html'
  12. })
  13. export class HeaderComponent implements OnInit {
  14. authState: Observable<fromAuth.State>;
  15. constructor(private dataStorageService: DataStorageService, private store: Store<fromApp.AppState>) {}
  16. ngOnInit() {
  17. this.authState = this.store.select('auth')
  18. }
  19. onSaveData() {
  20. this.store.dispatch(new RecipeActions.StoreRecipes());
  21. }
  22. onFetchData() {
  23. this.store.dispatch(new RecipeActions.FetchRecipes());
  24. }
  25. onLogout() {
  26. this.store.dispatch(new AuthActions.Logout());
  27. }
  28. }