Skip to content

Instantly share code, notes, and snippets.

@artberri
Created May 28, 2019 18:00
Show Gist options
  • Select an option

  • Save artberri/453e65bd3f5c801bfab2b0c73273265b to your computer and use it in GitHub Desktop.

Select an option

Save artberri/453e65bd3f5c801bfab2b0c73273265b to your computer and use it in GitHub Desktop.
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