This file contains 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
<script lang="ts"> | |
import { Component, Vue, Prop } from 'vue-property-decorator'; | |
import { Todo, ITodoView } from '../../../app/src'; | |
@Component | |
export class VueTodoMixin extends TodoMixin(Vue) {} | |
@Component({ | |
mixins: [VueTodoMixin] | |
}) |
This file contains 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
<div class="view"> | |
<input class="toggle" | |
type="checkbox" | |
[checked]="isCompleted" | |
(click)="onToggleCheckboxClicked()"> | |
<label (dblclick)="onDoubleClicked()">{{ todo.title }}</label> | |
<button class="destroy" (click)="onRemoveButtonClicked()"></button> | |
</div> | |
<input [(ngModel)]="todoTitleInput" | |
class="edit" |
This file contains 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, Input, HostBinding, OnInit } from '@angular/core'; | |
import { Todo, TodoMixin, ITodoView, TodoPresenter, Injector } from '../../../../../app/src'; | |
import { BaseView } from 'src/app/base.view'; | |
@Component({ | |
selector: '[app-todo]', | |
templateUrl: 'todo.template.html', | |
styles: [] | |
}) | |
export class TodoComponent extends TodoMixin(BaseView) implements ITodoView, OnInit { |
This file contains 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
// ... | |
describe('On toggle checkbox clicked', () => { | |
describe('when it is initially active', () => { | |
beforeEach(() => { | |
view.todo = activeTodo; | |
presenter.attach(view); | |
jest.clearAllMocks(); | |
}); | |
test('completes the todo', () => { |
This file contains 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 | |
) { |
This file contains 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 { Todo } from '../entities'; | |
export abstract class TodoStorageService { | |
public abstract getTodos(): Todo[]; | |
public abstract saveTodos(todos: Todo[]): void; | |
} |
This file contains 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 { Todo } from '../../model'; | |
import { Service, StateContainer } from '../../framework'; | |
@Service() | |
export class TodosState extends StateContainer<Todo[]> { | |
constructor() { | |
super([]); | |
} | |
public initialize(todos: Todo[]): void { |
This file contains 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
export class GetVisibleTodosQueryHandler extends SimpleQueryHandler<Todo[]> { | |
constructor( | |
private readonly filterState: FilterState, | |
private readonly todosState: TodosState | |
) { | |
super(GetVisibleTodosQuery); | |
} | |
public handle(): Todo[] { | |
switch (this.filterState.state) { |
This file contains 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 { CommandHandler, Service } from '../../../../framework'; | |
import { EditTodoCommand, IEditTodoPayload } from '../edit-todo.command'; | |
import { TodosState } from '../../../state'; | |
@Service() | |
export class EditTodoCommandHandler extends CommandHandler<IEditTodoPayload> { | |
constructor( | |
private readonly todosState: TodosState | |
) { | |
super(EditTodoCommand); |
This file contains 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 { Type, Injector } from '../framework'; | |
import { ITodoUserActions } from './todo.view'; | |
import { TodoPresenter } from '../presenters'; | |
// tslint:disable-next-line:typedef | |
export function TodoMixin<TBase extends Type>(base: TBase) { | |
return class extends base implements ITodoUserActions { | |
public presenter: TodoPresenter = Injector.resolve(TodoPresenter); | |
public onDoubleClicked(): void { |
NewerOlder