Last active
October 29, 2018 20:23
-
-
Save arturovt/2aef3634a605f11eb6c89bcc468f92cc 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 { Select } from '@ngxs/store'; | |
import { Emitter, Emittable } from '@ngxs-labs/emitter'; | |
import { CounterState } from './counter.state'; | |
@Component({ | |
selector: 'app-counter', | |
template: ` | |
<ng-container *ngIf="counter$ | async as counter"> | |
<h3>Counter is {{ counter.value }}</h3> | |
<div> | |
<button (click)="increment.emit()">Increment</button> | |
<button (click)="decrement.emit()">Decrement</button> | |
</div> | |
</ng-container> | |
` | |
}) | |
export class CounterComponent { | |
@Select(CounterState) | |
public counter$: Observable<number>; | |
@Emitter(CounterState.increment) | |
public increment: Emittable<void>; | |
@Emitter(CounterState.decrement) | |
public decrement: Emittable<void>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment