import { Store } from '../common/store' ; export class StoreService { public stores : Store [ ] = [ ] ; private _stores : { [ storeName ] : Store ; } = { } ; public register ( store ) { if ( this . _stores [ store . name ] ) { throw new Error ( `Store ${ store . name } already exists as a store.` ) ; } this . _stores [ store . name ] = store ; } public get ( storeName ) { if ( ! this . _stores [ storeName ] ) { throw new Error ( `Unable to locate ${ storeName }` ) ; } return this . _stores [ storeName ] ; } public reset ( ) { this . _stores = { } ; } }