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 { ID } from '@datorama/akita'; | |
| export interface List { | |
| name: string; | |
| id: ID; | |
| date: number | Date; | |
| total: number; | |
| items: (ID | Item)[]; | |
| } |
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 { Injectable } from '@angular/core'; | |
| import { EntityState, EntityStore } from '@datorama/akita'; | |
| import { List } from './shopping-list.model'; | |
| import { config } from '@datorama/akita'; | |
| export interface ListState extends EntityState<List> {} | |
| export interface ItemState extends EntityState<List> {} | |
| @Injectable({ | |
| providedIn: 'root' |
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 { Injectable } from '@angular/core'; | |
| import { QueryEntity } from '@datorama/akita'; | |
| import { ListStore, ItemStore, ListState, ItemState } from './shopping-list.store'; | |
| import { List, Item } from './shopping-list.model'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class ListQuery extends QueryEntity<ListState, List> { |
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 { Injectable } from '@angular/core'; | |
| import { Observable } from 'rxjs/index'; | |
| import { List, Item } from './shopika.model'; | |
| import { ID } from '@datorama/akita'; | |
| import { of } from 'rxjs'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class ShopikaDataService { |
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); |
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 { Component, OnInit, ChangeDetectionStrategy, Output, EventEmitter } from '@angular/core'; | |
| import { ListQuery, ListState, List } from '../state'; | |
| import { Observable } from 'rxjs'; | |
| import { ShopikaService } from '../state/shopika.service'; | |
| import { ID } from '@datorama/akita'; | |
| @Component({ | |
| selector: 'app-list', | |
| templateUrl: './list.component.html', | |
| styleUrls: ['./list.component.css'], |
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 { Component, OnInit, Input } from '@angular/core'; | |
| import { ItemQuery, ListQuery, List, Item, ShopikaService } from '../state'; | |
| import { ID } from '@datorama/akita'; | |
| @Component({ | |
| selector: 'app-edit', | |
| templateUrl: './edit.component.html', | |
| styleUrls: ['./edit.component.css'] | |
| }) |
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 { Injectable } from '@angular/core'; | |
| import { Observable } from 'rxjs/index'; | |
| import { List, Item } from './shopika.model'; | |
| import { ID } from '@datorama/akita'; | |
| import { of } from 'rxjs'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class ShopikaDataService { |
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 { List, Item, ShopikaService, ListQuery } from '../state'; | |
| import { ID } from '@datorama/akita'; | |
| export class EditComponent implements OnInit { | |
| list: List; | |
| constructor( | |
| private shopikaService: ShopikaService, | |
| private listQuery: ListQuery | |
| ) { } |
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 { ListQuery, List } from '../state'; | |
| import { ShopikaService } from '../state/shopika.service'; | |
| import { ID } from '@datorama/akita'; | |
| import { Observable } from 'rxjs'; | |
| export class ListsComponent implements OnInit { | |
| lists$: Observable<List[]>; | |
| constructor( | |
| private listQuery: ListQuery, |