diff --git a/github-users-web-client/pom.xml b/github-users-web-client/pom.xml
index f957ffb..2913271 100644
--- a/github-users-web-client/pom.xml
+++ b/github-users-web-client/pom.xml
@@ -113,6 +113,12 @@
-generateJsInteropExports,-optimize,9,-XnoclassMetadata
+
+
+ org.codehaus.mojo
+ gwt-maven-plugin
+ ${gwt.version}
+
diff --git a/github-users-web-client/src/main/java/com/xemantic/ankh/Elements.java b/github-users-web-client/src/main/java/com/xemantic/ankh/Elements.java
index 84c1bbf..de09fff 100644
--- a/github-users-web-client/src/main/java/com/xemantic/ankh/Elements.java
+++ b/github-users-web-client/src/main/java/com/xemantic/ankh/Elements.java
@@ -23,7 +23,7 @@
package com.xemantic.ankh;
import com.intendia.rxgwt.elemental2.RxElemental2;
-import com.xemantic.githubusers.logic.eventbus.Trigger;
+import com.xemantic.githubusers.logic.event.Trigger;
import elemental2.dom.Element;
import elemental2.dom.Event;
import elemental2.dom.HTMLButtonElement;
diff --git a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/GitHubUsersModule.java b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/GitHubUsersModule.java
index 299f47d..de60174 100644
--- a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/GitHubUsersModule.java
+++ b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/GitHubUsersModule.java
@@ -26,8 +26,9 @@
import com.intendia.gwt.autorest.client.ResourceVisitor;
import com.xemantic.githubusers.logic.driver.UrlOpener;
import com.xemantic.githubusers.logic.error.ErrorAnalyzer;
-import com.xemantic.githubusers.logic.eventbus.DefaultEventBus;
-import com.xemantic.githubusers.logic.eventbus.EventBus;
+import com.xemantic.githubusers.logic.event.SnackbarMessageEvent;
+import com.xemantic.githubusers.logic.event.UserQueryEvent;
+import com.xemantic.githubusers.logic.event.UserSelectedEvent;
import com.xemantic.githubusers.logic.service.UserService;
import com.xemantic.githubusers.logic.view.*;
import com.xemantic.githubusers.web.driver.WebUrlOpener;
@@ -38,8 +39,12 @@
import dagger.Module;
import dagger.Provides;
+import java.util.function.Consumer;
import javax.inject.Named;
import javax.inject.Singleton;
+import rx.Observable;
+import rx.Observer;
+import rx.subjects.PublishSubject;
/**
* Dagger module defining component binding for the whole app.
@@ -71,11 +76,20 @@ static String getProjectGitHubUrl() {
return "https://github.com/xemantic/github-users-web";
}
- @Provides
- @Singleton
- static EventBus getEventBus() {
- return new DefaultEventBus();
- }
+ // Snackbar message event bus
+ @Provides @Singleton static PublishSubject snackbarMessageBus() { return PublishSubject.create(); }
+ @Provides static Consumer snackbarMessageConsumer(PublishSubject bus) { return bus::onNext; }
+ @Binds abstract Observable snackbarMessageObservable(PublishSubject bus);
+
+ // User query event bus
+ @Provides @Singleton static PublishSubject userQueryBus() { return PublishSubject.create(); }
+ @Provides static Consumer userQueryConsumer(PublishSubject bus) { return bus::onNext; }
+ @Binds abstract Observable userQueryObservable(PublishSubject bus);
+
+ // User selected event bus
+ @Provides @Singleton static PublishSubject userSelectedBus() { return PublishSubject.create(); }
+ @Provides static Consumer userSelectedConsumer(PublishSubject bus) { return bus::onNext; }
+ @Binds abstract Observable userSelectedObservable(PublishSubject bus);
@Binds
abstract ErrorAnalyzer getErrorAnalyzer(DefaultErrorAnalyzer analyzer);
diff --git a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/error/ExceptionHandler.java b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/error/ExceptionHandler.java
index 895b1d5..02b3fa2 100644
--- a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/error/ExceptionHandler.java
+++ b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/error/ExceptionHandler.java
@@ -24,10 +24,11 @@
import com.google.gwt.core.client.GWT;
import com.xemantic.githubusers.logic.event.SnackbarMessageEvent;
-import com.xemantic.githubusers.logic.eventbus.EventBus;
+import java.util.function.Consumer;
import javax.inject.Inject;
import javax.inject.Singleton;
+import rx.Observer;
/**
* Handler of uncaught exceptions in this app. It will log the error using
@@ -39,11 +40,11 @@
@Singleton
public class ExceptionHandler implements GWT.UncaughtExceptionHandler {
- private final EventBus eventBus;
+ private final Consumer snackbarMessageConsumer;
@Inject
- public ExceptionHandler(EventBus eventBus) {
- this.eventBus = eventBus;
+ public ExceptionHandler(Consumer snackbarMessageConsumer) {
+ this.snackbarMessageConsumer = snackbarMessageConsumer;
}
/** {@inheritDoc} */
@@ -54,7 +55,7 @@ public void onUncaughtException(Throwable e) {
// use this method if you need to notify user about certain errors.
private void postSnackbarMessage(String message) {
- eventBus.post(new SnackbarMessageEvent(message));
+ snackbarMessageConsumer.accept(new SnackbarMessageEvent(message));
}
}
diff --git a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/navigation/UserSelectionNavigator.java b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/navigation/UserSelectionNavigator.java
index 59afb78..bff2c41 100644
--- a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/navigation/UserSelectionNavigator.java
+++ b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/navigation/UserSelectionNavigator.java
@@ -24,10 +24,10 @@
import com.xemantic.githubusers.logic.driver.UrlOpener;
import com.xemantic.githubusers.logic.event.UserSelectedEvent;
-import com.xemantic.githubusers.logic.eventbus.EventBus;
import javax.inject.Inject;
import javax.inject.Singleton;
+import rx.Observable;
/**
* Will open user profile page if the user is selected.
@@ -37,22 +37,21 @@
@Singleton
public class UserSelectionNavigator {
- private final EventBus eventBus;
+ private final Observable userSelected$;
private final UrlOpener urlOpener;
@Inject
public UserSelectionNavigator(
- EventBus eventBus,
+ Observable userSelected$,
UrlOpener urlOpener) {
- this.eventBus = eventBus;
+ this.userSelected$ = userSelected$;
this.urlOpener = urlOpener;
}
public void start() {
- eventBus.observe(UserSelectedEvent.class)
- .subscribe(event -> urlOpener.openUrl(event.getUser().getHtmlUrl()));
+ userSelected$.subscribe(event -> urlOpener.openUrl(event.getUser().getHtmlUrl()));
}
}
diff --git a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/service/GitHubApiErrorHandler.java b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/service/GitHubApiErrorHandler.java
index bcee85b..0e1b72d 100644
--- a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/service/GitHubApiErrorHandler.java
+++ b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/service/GitHubApiErrorHandler.java
@@ -24,10 +24,11 @@
import com.intendia.gwt.autorest.client.RequestResourceBuilder.FailedStatusCodeException;
import com.xemantic.githubusers.logic.event.SnackbarMessageEvent;
-import com.xemantic.githubusers.logic.eventbus.EventBus;
+import java.util.function.Consumer;
import javax.inject.Inject;
import javax.inject.Singleton;
+import rx.Observer;
/**
* Error handler for GitHub APIs.
@@ -37,11 +38,11 @@
@Singleton
public class GitHubApiErrorHandler {
- private final EventBus eventBus;
+ private final Consumer snackbarMessageConsumer;
@Inject
- public GitHubApiErrorHandler(EventBus eventBus) {
- this.eventBus = eventBus;
+ public GitHubApiErrorHandler(Consumer snackbarMessageConsumer) {
+ this.snackbarMessageConsumer = snackbarMessageConsumer;
}
public void handleError(Throwable throwable) {
@@ -56,7 +57,7 @@ && handleStatusCode((FailedStatusCodeException) throwable)
private boolean handleStatusCode(FailedStatusCodeException e) {
String message = getMessage(e.getStatusCode());
if (message != null) {
- eventBus.post(new SnackbarMessageEvent(message));
+ snackbarMessageConsumer.accept(new SnackbarMessageEvent(message));
return true;
}
return false;
diff --git a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebDrawerView.java b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebDrawerView.java
index 0608d05..edbefd6 100644
--- a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebDrawerView.java
+++ b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebDrawerView.java
@@ -24,7 +24,7 @@
import com.xemantic.ankh.Elements;
import com.xemantic.ankh.IncrementalDom;
-import com.xemantic.githubusers.logic.eventbus.Trigger;
+import com.xemantic.githubusers.logic.event.Trigger;
import com.xemantic.githubusers.logic.view.DrawerView;
import elemental2.dom.Element;
import mdc.drawer.MDCTemporaryDrawer;
diff --git a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebUserListView.java b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebUserListView.java
index 2d01bbf..10a70e4 100644
--- a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebUserListView.java
+++ b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebUserListView.java
@@ -24,7 +24,7 @@
import com.xemantic.ankh.Elements;
import com.xemantic.ankh.IncrementalDom;
-import com.xemantic.githubusers.logic.eventbus.Trigger;
+import com.xemantic.githubusers.logic.event.Trigger;
import com.xemantic.githubusers.logic.view.UserListView;
import com.xemantic.githubusers.logic.view.UserView;
import elemental2.dom.Element;
diff --git a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebUserView.java b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebUserView.java
index b945352..e7d8262 100644
--- a/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebUserView.java
+++ b/github-users-web-client/src/main/java/com/xemantic/githubusers/web/view/WebUserView.java
@@ -22,7 +22,7 @@
package com.xemantic.githubusers.web.view;
import com.xemantic.ankh.Elements;
-import com.xemantic.githubusers.logic.eventbus.Trigger;
+import com.xemantic.githubusers.logic.event.Trigger;
import com.xemantic.githubusers.logic.model.User;
import com.xemantic.githubusers.logic.view.UserView;
import com.xemantic.ankh.IncrementalDom;