Created
June 18, 2016 14:15
-
-
Save pearofducks/7e053fe6ad785c5290ca68ac3e23bcaf to your computer and use it in GitHub Desktop.
mobx basic crud
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
class FooStore { | |
@observable foos = [] | |
getFoos = () => { | |
return this.foos | |
} | |
getFoo = id => { | |
return this.foos.find(foo => foo.id === id) | |
} | |
addFoo = text => { | |
this.foos.push({ id: Math.random(), bar }) | |
} | |
removeFoo = id => { | |
this.foos = this.foos.filter(foo => foo.id !== id) | |
} | |
} | |
const fooStore = new FooStore() | |
export default fooStore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment