import { Injectable } from "@angular/core"; import { Utility } from "./utility"; import { IRslt, TaxTable, Track, BankAccount, Account } from "../../public-api"; import { BankService } from "../services/bankService"; /** * Exposes the User endpoint * */ @Injectable({ providedIn: 'root' }) export class BankState { constructor(private service:BankService) { } // get(error:any) { // const self = this; // this.service.get().subscribe({ // next(rslt: { results: TaxTable[]; }) { // // if (rslt) { // // self.utility.update(self.taxes, rslt.results) // // } // }, error(e) { // }, complete() { // } // }) // } getByID(id: string, done:any, error:any) { const self = this; this.service.getByID(id).subscribe({ next(rslt: IRslt) { if (rslt) { done(rslt.results) // self.utility.updateRslt(self., rslt) } }, error(e) { error(e) }, complete() { // done() } }) } post(bank: BankAccount,done:any, error:any) { // const self = this; this.service.post(bank).subscribe({ next(rslt: IRslt) { if (rslt) { done(rslt.results) } }, error(e) { error(e) }, complete() { } }) } put(bank: BankAccount,done:any, error:any) { // const self = this; this.service.put(bank).subscribe({ next(rslt: IRslt) { if (rslt) { done(rslt.results) } }, error(e) { error(e) }, complete() { } }) } // put(track: TaxTable, done:any) { // const self = this; // this.service.put(track).subscribe({ // next(rslt: IRslt) { // if (rslt) { // self.utility.updateRslt(self.taxes, rslt) // } // }, error(e) { // }, complete() { // done(); // } // }) // } delete(track: BankAccount, done:any) { // const self = this; this.service.delete(track).subscribe({ next(rslt: { results: string; }) { if (rslt) { done(rslt.results) // rslt.results.forEach((f:TaxTable) => { // const index = self.taxes.findIndex(fi => f._id === fi._id); // if(index >=0){ // self.taxes.splice(index,1) // } // }) } }, error(e) { done(); }, complete() { } }) } }