//import { Injectable } from '@angular/core'; //import { BehaviorSubject, Observable } from 'rxjs'; //import { HttpClient } from '@angular/common/http'; //import { tap, map } from 'rxjs/operators'; //import { rosterList } from './roster'; //const CREATE_ACTION = 'create'; //const UPDATE_ACTION = 'update'; //const REMOVE_ACTION = 'destroy'; //@Injectable() //export class RosterService extends BehaviorSubject { // constructor(private http: HttpClient) { // super([]); // } // private data: any[] = []; // public read() { // if (this.data.length) { // return super.next(this.data); // } // this.fetch() // .pipe( // tap(data => { // this.data = data; // }) // ) // .subscribe(data => { // super.next(data); // }); // } // public save(data: any, isNew?: boolean) { // const action = isNew ? CREATE_ACTION : UPDATE_ACTION; // this.reset(); // this.fetch(action, data) // .subscribe(() => this.read(), () => this.read()); // } // public remove(data: any) { // this.reset(); // this.fetch(REMOVE_ACTION, data) // .subscribe(() => this.read(), () => this.read()); // } // public resetItem(dataItem: any) { // if (!dataItem) { return; } // // find orignal data item // const originalDataItem = this.data.find(item => item.id === dataItem.id); // // revert changes // Object.assign(originalDataItem, dataItem); // super.next(this.data); // } // private reset() { // this.data = []; // } // private fetch(action: string = '', data?: any): Observable { // //return this.http // // .jsonp(`https://demos.telerik.com/kendo-ui/service/Products/${action}?${this.serializeModels(data)}`, 'callback') // // .pipe(map(res => res)); // // // return this.getrosters(); // } // private serializeModels(data?: any): string { // return data ? `&models=${JSON.stringify([data])}` : ''; // } // public getrosters(): any { // const rolesObservable = new Observable(observer => { // setTimeout(() => { // observer.next(rosterList); // }, 1000); // }); // return rolesObservable; // } //}