Skip to content

Instantly share code, notes, and snippets.

@avilde
Created August 12, 2021 06:17
Show Gist options
  • Save avilde/efe31cec1b151d21c4dabfd21b1d70e4 to your computer and use it in GitHub Desktop.
Save avilde/efe31cec1b151d21c4dabfd21b1d70e4 to your computer and use it in GitHub Desktop.
Mobx State Example
import { makeAutoObservable } from "mobx"
export class BalanceState {
balance = 1000
constructor() {
makeAutoObservable(this)
}
add(value: number) {
this.balance = this.balance + value
}
withdraw(value: number) {
this.balance = this.balance - value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment