import {Iterator, Map} from 'immutable'; export class FunsCustomerController { private store: Map boolean | Promise>; constructor() { this.store = Map(); } public setCustomer(key: string, func: any) { if (this.store.has(key)) { throw new Error('found exist customer: ' + key); } this.store = this.store.set(key, func); } public getCustomer(key: string) { if (!this.store.has(key)) { console.error('can not find dataCustomer: ' + key); } return this.store.get(key); } public clearCustomer() { return this.store.clear(); } public getAllCustomerName(): Iterator { return this.store.keys(); } public delCustomer(funcName: string) { this.store = this.store.delete(funcName); } } export default new FunsCustomerController();