diff options
Diffstat (limited to 'app/boot/wire-up-components-into.js')
| -rw-r--r-- | app/boot/wire-up-components-into.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/app/boot/wire-up-components-into.js b/app/boot/wire-up-components-into.js index b4cbc66..7875bdf 100644 --- a/app/boot/wire-up-components-into.js +++ b/app/boot/wire-up-components-into.js @@ -2,7 +2,7 @@ import * as commands from '../services/commands'; import * as queries from '../services/queries'; import Api from '../infrastructure/api'; import ApplicationStorage from '../infrastructure/application-storage'; -import Config from 'react-native-config'; +import Configuration from '../infrastructure/configuration'; import EventAggregator from '../infrastructure/event-aggregator'; import Registry from '../infrastructure/registry'; import Router from '../infrastructure/router' @@ -20,21 +20,25 @@ export default class WireUpComponentsInto { }); }).asSingleton(); this.registry.register('applicationStorage', ApplicationStorage).asSingleton(); - let host = Config.API_HOST; - this.registry.register('sessionsApi', (container) => new Api(host, '/sessions', container.resolve('applicationStorage'))).asSingleton(); - this.registry.register('workoutsApi', (container) => new Api(host, '/workouts', container.resolve('applicationStorage'))).asSingleton(); + this.registry.register('configuration', () => { + return new Configuration('development'); + }).asSingleton(); + this.registry.register('api', Api).asSingleton(); + this.registerSubscribers(commands); this.registerSubscribers(queries); + + this.registry.resolveAll("subscriber").forEach((subscriber) => { + console.log(`subscribing: ${subscriber}`); + subscriber.subscribeTo(this.registry.resolve('eventAggregator')); + }); return this.registry; } registerSubscribers(subscribers) { for (let subscriber in subscribers) { - //console.log(`registering: ${subscriber}`); + console.log(`registering: ${subscriber}`); this.registry.register('subscriber', subscribers[subscriber]).asSingleton(); } - this.registry.resolveAll("subscriber").forEach((subscriber) => { - subscriber.subscribeTo(this.registry.resolve('eventAggregator')); - }); } } |
