Last active
May 9, 2020 15:24
-
-
Save splincode/0573fb3b10c0f0bc01f05b4e39adda4f to your computer and use it in GitHub Desktop.
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 { 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