Skip to content

Instantly share code, notes, and snippets.

@jennifer-shehane
Last active June 24, 2016 19:56
Show Gist options
  • Save jennifer-shehane/71532ac68032d20941ad57dafae2abc1 to your computer and use it in GitHub Desktop.
Save jennifer-shehane/71532ac68032d20941ad57dafae2abc1 to your computer and use it in GitHub Desktop.
import { computed, observable, action } from 'mobx'
class Projects {
@observable projects = []
constructor (projects) {
this.projects = projects
}
removeProject (projectId) {
// this removes ALL projects
this.projects = _.filter(this.projects, (project) => {
!(project.id === projectId)
})
}
removeProject (projectId) {
// this removes 1 project
this.projects = _.filter(this.projects, (project) => !(project.id === projectId))
}
}
projects = new Projects([{id: '123', path: 'foo'}, {id: '456', path: 'bar'}])
projects.removeProject('123')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment