Last active
August 21, 2018 08:22
-
-
Save YonathanMeguira/ac1710d17ff9ab635372893c1300a6c6 to your computer and use it in GitHub Desktop.
shopping-service.ts
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 { ListStore } from './shopika.store'; | |
import { List, Item } from './shopika.model'; | |
import { ID, update } from '@datorama/akita'; | |
export class ShopikaService { | |
constructor(private listStore: ListStore) { | |
} | |
addList(list: List) { | |
this.listStore.add(list); | |
} | |
updateList(data: List, item: Item, purchased: boolean) { | |
this.listStore.update(data.id, list => { | |
return { | |
...list, | |
items: update(data.items, item, {purchased}) | |
} | |
}); | |
} | |
selectList(id: ID) { | |
this.listStore.setActive(id); | |
} | |
deleteList(id: ID) { | |
this.listStore.remove(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment