Skip to content

Instantly share code, notes, and snippets.

@JeffryGonzalez
Created February 1, 2021 21:13
Show Gist options
  • Select an option

  • Save JeffryGonzalez/292f1dd25f8ea629833835599cc04aa4 to your computer and use it in GitHub Desktop.

Select an option

Save JeffryGonzalez/292f1dd25f8ea629833835599cc04aa4 to your computer and use it in GitHub Desktop.
shopping
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);
}
}
@jubalviolanna-arch

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment