Last active
August 31, 2019 19:08
-
-
Save splincode/6ae1ec4d896c56bb9643f8bfa0188cd7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 } from '@angular/core'; | |
import { Store, Select } from '@ngxs/store'; | |
import { Observable } from 'rxjs'; | |
import { Dispatch } from '@ngxs-labs/dispatch-decorator' | |
import { CountState } from './store/counter/count.state'; | |
import { Increment, Decrement } from './store/counter/count.actions'; | |
@Component({ | |
selector: 'my-app', | |
template: ` | |
<p> | |
NGXS counter: {{ count$ | async }} | |
<button (click)="increment()">+</button> | |
<button (click)="decrement()">-</button> | |
</p> | |
` | |
}) | |
export class AppComponent { | |
@Select(CountState) count$: Observable<number>; | |
@Dispatch() public increment = () => new Increment(); | |
@Dispatch() public decrement = () => new Decrement(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment