Skip to content

Instantly share code, notes, and snippets.

@splincode
Created February 15, 2019 21:45
Show Gist options
  • Save splincode/b9af2d3ffaac59fcf08be4924dc03a74 to your computer and use it in GitHub Desktop.
Save splincode/b9af2d3ffaac59fcf08be4924dc03a74 to your computer and use it in GitHub Desktop.
import { Dispatch } from '@ngxs-labs/dispatch-decorator';
...
@Component({
selector: 'my-app',
template: `
{{ stateA$ | async }}
{{ stateB$ | async }}
{{ stateC$ | async }}
...
<button (click)="actionA()">actionA</button>
<button (click)="actionB()">actionB</button>
<button (click)="actionC()">actionC</button>
...
`
})
export class AppComponent {
@Select(StateA) public stateA$: Observable<any>;
@Select(StateB) public stateB$: Observable<any>;
@Select(StateC) public stateC$: Observable<any>;
...
@Dispatch() public actionA = () => new ActionA();
@Dispatch() public actionB = () => new ActionB();
@Dispatch() public actionC = () => new ActionC();
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment