import StoreWithMetadata from './StoreWithMetadata' export default new class StoreManager { private stores = new Map() getStoreAndMetadataFor(storeSourceClass: any): StoreWithMetadata { let storeWithMetadata = this.stores.get(storeSourceClass) if (storeWithMetadata !== undefined) { return storeWithMetadata } storeWithMetadata = new StoreWithMetadata(new storeSourceClass) this.stores.set(storeSourceClass, storeWithMetadata) return storeWithMetadata } get state(): {[storeSourceClass: string]: any} { const state: {[storeSourceClass: string]: any} = {} for (const storeSourceClass of this.stores.keys()) { state[storeSourceClass.name] = this.stores.get(storeSourceClass)!.state } return state } }