Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created December 24, 2019 13:43
Show Gist options
  • Save lydemann/e8f2f025abf581eb7b288adcb66ae7b2 to your computer and use it in GitHub Desktop.
Save lydemann/e8f2f025abf581eb7b288adcb66ae7b2 to your computer and use it in GitHub Desktop.
todo-list.component.ts
export class TodoListComponent implements OnInit {
public selectedTodo$ = this.todoListSandboxService.selectedTodo$;
public todoList: TodoItem[];
public isLoading = false;
constructor(private todoListSandboxService: TodoListSandboxService) {}
public ngOnInit(): void {
// mapping to state property - don't do this!
this.todoListSandboxService.todoList$.subscribe(todoList => {
this.todoList = todoList;
});
this.todoListSandboxService.isLoading$.subscribe(isLoading => {
this.isLoading = isLoading;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment