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
it('emits all other heroes immediately', fakeAsync(() => { | |
const elektra: Hero = femaleMarvelHeroes.find(x => x.name === 'Elektra'); | |
container.delete(elektra); | |
tick(); | |
expect(observer).toHaveBeenCalledWith( | |
femaleMarvelHeroes.filter(x => x.id !== elektra.id)); | |
})); |
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
it('emits the specified hero when server fails', fakeAsync(() => { | |
heroServiceStub.deleteHero.and.returnValue( | |
throwError(new Error('timeout'), asapScheduler)); | |
const storm: Hero = femaleMarvelHeroes.find(x => x.name === 'Storm'); | |
container.delete(storm); | |
tick(); | |
const emittedHeroes: Hero[] = observer.calls.mostRecent().args[0]; | |
emittedHeroes.sort(compareIdAscending); |
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
src | |
└── app | |
├── dashboard | |
│ ├── dashboard.component.css | |
│ ├── dashboard.component.html | |
│ ├── dashboard.component.spec.ts | |
│ ├── dashboard.component.ts | |
│ ├── dashboard.container.html | |
│ ├── dashboard.container.spec.ts | |
│ └── dashboard.container.ts |
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
heroes | |
├── heroes.component.css | |
├── heroes.component.html | |
├── heroes.component.spec.ts | |
├── heroes.component.ts | |
├── heroes.container.html | |
├── heroes.container.spec.ts | |
└── heroes.container.ts |
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
public class TodoItem | |
{ | |
public string Id { get; set; } | |
public bool IsDone { get; set; } | |
public string Title { get; set; } | |
public async Task Save() | |
{ | |
// Write to database | |
} |
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
class TodoItem { | |
id: string; | |
isDone: boolean; | |
title: string; | |
save(): Promise<void> { | |
return fetch("/todo/" + this.id, { | |
body: JSON.stringify(this), | |
method: "POST", | |
}) |
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
class EditTodoItemView { | |
todoItem: TodoItem; | |
onInitialize(id: string): Promise<void> { | |
return this.readTodoItem(id) | |
.then(todoItem => this.todoItem = todoItem) | |
.then(() => undefined); | |
} | |
readTodoItem(id: string): Promise<TodoItem> { |
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
class TodoItem { | |
id: string; | |
isDone: boolean; | |
title: string; | |
constructor(properties) { | |
this.id = properties.id; | |
this.isDone = properties.isDone; | |
this.title = properties.title; | |
} |
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
class EditTodoItemView { | |
todoItem: TodoItem; | |
onInitialize(id: string): Promise<void> { | |
return this.readTodoItem(id) | |
.then(todoItem => this.todoItem = todoItem) | |
.then(() => undefined); | |
} | |
readTodoItem(id: string): Promise<TodoItem> { |
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, OnInit } from '@angular/core'; | |
import { Hero } from '../hero'; | |
import { HeroService } from '../hero.service'; | |
@Component({ | |
selector: 'app-heroes', | |
templateUrl: './heroes.container.html', | |
}) | |
export class HeroesContainerComponent implements OnInit { |