From 7d90898404009e5ee8549d74a2ec96bd627da342 Mon Sep 17 00:00:00 2001 From: Thibault Deutsch Date: Sat, 9 Dec 2017 16:31:57 +0100 Subject: [PATCH] Connect reducer --- src/main/java/com/epita/guereza/Main.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/epita/guereza/Main.java b/src/main/java/com/epita/guereza/Main.java index 4f71dcb..169b792 100644 --- a/src/main/java/com/epita/guereza/Main.java +++ b/src/main/java/com/epita/guereza/Main.java @@ -75,12 +75,22 @@ private static void runIndexer(Scope scope) { private static void runStore(Scope scope) { final Function newUrlStore = (s) -> new UrlStore(s.instanceOf(EventBusClient.class)); + final Function newRetroIndex = (s) -> new RetroIndex(); final Function newEventStoreApp = (s) -> new EventStoreApp( s.instanceOf(EventBusClient.class), s.instanceOf(EventStore.class)); scope.scope() .register(new Singleton<>(EventStore.class, new EventStore())) - .register(new LazySingleton<>(UrlStore.class, newUrlStore)) + .register(new LazySingleton<>(UrlStore.class, newUrlStore) + .afterCreate((s, obj) -> { + EventStore eventStore = s.instanceOf(EventStore.class); + eventStore.addReducer(obj); + })) + .register(new LazySingleton<>(RetroIndex.class, newRetroIndex) + .afterCreate((s, obj) -> { + EventStore eventStore = s.instanceOf(EventStore.class); + eventStore.addReducer(obj); + })) .register(new Prototype<>(App.class, newEventStoreApp)) .block(Main::runApp); }