Last active
November 11, 2019 21:32
-
-
Save evgenyfedorenko/c6b0e3105bccd6dea7c5d0c5dea50170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { Observable } from 'rxjs'; | |
import * as fromRoot from './reducers/'; | |
import { Increment, Decrement, Reset } from './actions/counter.actions'; | |
import { StoreService, select } from './store.service'; | |
@Component({ | |
selector: 'my-app', | |
templateUrl: './app.component.html', | |
}) | |
export class AppComponent implements OnInit { | |
counter: Observable<number>; | |
constructor( | |
private storeService: StoreService | |
) { } | |
ngOnInit() { | |
this.counter = this.storeService.getState().pipe(select(fromRoot.getCount)); | |
} | |
increment() { | |
this.storeService.dispatch(new Increment()); | |
} | |
decrement() { | |
this.storeService.dispatch(new Decrement()); | |
} | |
reset() { | |
this.storeService.dispatch(new Reset()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment