Skip to content

Instantly share code, notes, and snippets.

@mwistrand
mwistrand / smart-dumb-component.ts
Created August 29, 2018 19:30
`app-dumb`'s count is never updated until the button is clicked
@Component({
selector: 'app-dumb',
template: '{{data?.length}}'
})
class DumbComponent {
@Input() data: Item[];
}
@Component({
selector: 'app-smart',
@mwistrand
mwistrand / state.service.ts
Last active November 7, 2020 23:35
Service-based State Management in Angular
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import 'rxjs/add/operator/scan';
export enum ActionType {
ADD_TYPE = 'ADD_TYPE',
REMOVE_TYPE = 'REMOVE_TYPE'
}
export interface Action<T> {