MCPcopy
hub / github.com/greenrobot/EventBus / register

Method register

EventBus/src/org/greenrobot/eventbus/EventBus.java:142–156  ·  view source on GitHub ↗

Registers the given subscriber to receive events. Subscribers must call #unregister(Object) once they are no longer interested in receiving events. Subscribers have event handling methods that must be annotated by Subscribe. The Subscribe annotation also allows configura

(Object subscriber)

Source from the content-addressed store, hash-verified

140 * ThreadMode} and priority.
141 */
142 public void register(Object subscriber) {
143 if (AndroidDependenciesDetector.isAndroidSDKAvailable() && !AndroidDependenciesDetector.areAndroidComponentsAvailable()) {
144 // Crash if the user (developer) has not imported the Android compatibility library.
145 throw new RuntimeException("It looks like you are using EventBus on Android, " +
146 "make sure to add the \"eventbus\" Android library to your dependencies.");
147 }
148
149 Class<?> subscriberClass = subscriber.getClass();
150 List<SubscriberMethod> subscriberMethods = subscriberMethodFinder.findSubscriberMethods(subscriberClass);
151 synchronized (this) {
152 for (SubscriberMethod subscriberMethod : subscriberMethods) {
153 subscribe(subscriber, subscriberMethod);
154 }
155 }
156 }
157
158 // Must be called in synchronized block
159 private void subscribe(Object subscriber, SubscriberMethod subscriberMethod) {

Callers 15

onCreateMethod · 0.80
runTestMethod · 0.80
registerSubscribersMethod · 0.80
runTestMethod · 0.80
registerSubscribersMethod · 0.80
runMethod · 0.80
testPostMethod · 0.80

Calls 4

isAndroidSDKAvailableMethod · 0.95
subscribeMethod · 0.95
findSubscriberMethodsMethod · 0.80

Tested by 15

onCreateMethod · 0.64
runTestMethod · 0.64
registerSubscribersMethod · 0.64
runTestMethod · 0.64
registerSubscribersMethod · 0.64
runMethod · 0.64
testPostMethod · 0.64