@RxBusSubscribe(queuing = false, mode = RxBusMode.Main)
public void onEvent(Event event) {
// handle bus event here
}
@RxBusSubscribe(queuing = false, mode = RxBusMode.Main, key = R.integer.key1)
public void onEvent(Event event) {
// handle bus event here
}
@RxBusSubscribe(queuing = true, mode = RxBusMode.Background, keys = {R.integer.key1, R.integer.key2})
public void onEvent(Event event) {
// handle bus event here
}
@RxBusSubscribe(queuing = true, mode = RxBusMode.Background, keys = {"key1", "key2"})
public void onEvent(Event event) {
// handle bus event here
}
Idea
Define subcriptions via annotations:
Annotation processor should generate functions in this class:
user calls
subscribeRxBusEvents()wherever he wants to subscribe all annotated functions in this class to bus - manuallyuser also calls
unsubscribeRxBusEvents()wherever he wants to unsubscribe all annotated functions in this class from bus - manuallySettings
@RxBusSubscribehas following annotation fields:queuing... defines theRxBusBuilderswithQueuingvaluemode... defines theRxBusBuilderswithModevaluekey/keys... defines theRxBusBuilderswithKeyvalueRxBusBuilder.create(<CLASS>.class)is derived from the annotated functions parameter class.public void onEvent(Event event)will generate aRxBusBuilder.create(Event.class)code lineExamples
TODO
Activity/Fragment/...). This could generate code that subscribes to the bus in the constructor/onCreate/onResumeand unsubscribes them in the appropriate counter function