Skip to content

Instantly share code, notes, and snippets.

@splincode
Last active May 9, 2020 15:24
Show Gist options
  • Save splincode/0573fb3b10c0f0bc01f05b4e39adda4f to your computer and use it in GitHub Desktop.
Save splincode/0573fb3b10c0f0bc01f05b4e39adda4f to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { Store } from './store';
interface CountModel {
value: number;
}
@Injectable()
export class CounterStore extends Store<CountModel> {
private initialCount: CountModel = { value: 0 };
constructor() {
super(this.initialCount);
}
public setCount(val: number): void {
this.setState({ value: this.getState().value + val });
}
public reset(): void {
this.setState(this.initialCount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment