Created
May 28, 2019 18:00
-
-
Save artberri/453e65bd3f5c801bfab2b0c73273265b 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 { Service, BasePresenter, Mediator } from '../framework'; | |
| import { AppState, LoadTodosCommand, SaveTodosCommand, GetAllTodosQuery, ContainsAnyTodosQuery } from '../model'; | |
| import { IAppView } from '../views'; | |
| @Service() | |
| export class AppPresenter extends BasePresenter<IAppView> { | |
| constructor( | |
| private readonly mediator: Mediator, | |
| private readonly state: AppState | |
| ) { | |
| super(); | |
| } | |
| protected init(): void { | |
| this.mediator.send(new LoadTodosCommand()); | |
| this.state.subscribe(() => { | |
| this.mediator.send(new SaveTodosCommand(this.mediator.send(new GetAllTodosQuery()))); | |
| this.mediator.send(new ContainsAnyTodosQuery()) ? this.view.showList() : this.view.hideList(); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment