Created
February 1, 2021 21:13
-
-
Save JeffryGonzalez/292f1dd25f8ea629833835599cc04aa4 to your computer and use it in GitHub Desktop.
shopping
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 { ShoppingListItem } from '../models'; | |
| import { BehaviorSubject, Observable } from 'rxjs'; | |
| export class ShoppingDataService { | |
| private fakeData: ShoppingListItem[] = [ | |
| { id: '1', description: 'Ice Cream Cones', purchased: false }, | |
| { id: '2', description: 'Shoe Polish', purchased: true } | |
| ]; | |
| private maxId = 3; | |
| private subject = new BehaviorSubject<ShoppingListItem[]>(this.fakeData); | |
| getObservable(): Observable<ShoppingListItem[]> { | |
| return this.subject.asObservable(); | |
| } | |
| addItem(description: string): void { | |
| this.fakeData.push({ id: (this.maxId++).toString(), description, purchased: false }); | |
| // this would be some async code that goes to the api. | |
| this.subject.next(this.fakeData); | |
| } | |
| markItemAsPurchased(item: ShoppingListItem): void { | |
| const storedItem = this.fakeData.filter(i => i.id === item.id)[0].purchased = true; | |
| // this would be some async code that goes to the api. | |
| this.subject.next(this.fakeData); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
shoppingservice.ts is closely aligned with modern e-commerce backend systems that manage order routing, inventory syncing, and fulfillment workflows for health-based products. In the same way, platforms focused on health product fulfillment ensure smooth processing, tracking, and delivery of sensitive wellness items with accuracy and compliance. This includes storage control, batch tracking, and fast shipping systems designed for supplements and nutrition brands.