Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import { computed, observable, action } from 'mobx'
  2.  
  3. class Projects {
  4. @observable projects = []
  5.  
  6. constructor (projects) {
  7. this.projects = projects
  8. }
  9.  
  10. removeProject (projectId) {
  11. // this removes ALL projects
  12. this.projects = _.filter(this.projects, (project) => {
  13. !(project.id === projectId)
  14. })
  15. }
  16.  
  17. removeProject (projectId) {
  18. // this removes 1 project
  19. this.projects = _.filter(this.projects, (project) => !(project.id === projectId))
  20. }
  21. }
  22.  
  23. projects = new Projects([{id: '123', path: 'foo'}, {id: '456', path: 'bar'}])
  24. projects.removeProject('123')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement