You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@RxBusSubscribe
public void onEvent(Event event) {
// handle bus event here
}
Annotation processor should generate functions in this class:
public final void subscribeRxBusEvents() {
// generated code
// disposables must be managed by the class so those are bound to this class
}
public final void unsubscribeRxBusEvents() {
RxDisposableManager.unsubscribe(this);
}
user calls subscribeRxBusEvents() wherever he wants to subscribe all annotated functions in this class to bus - manually
user also calls unsubscribeRxBusEvents() wherever he wants to unsubscribe all annotated functions in this class from bus - manually
Settings
@RxBusSubscribe has following annotation fields:
queuing... defines the RxBusBuilders withQueuing value
mode... defines the RxBusBuilders withMode value
key/keys... defines the RxBusBuilders withKey value
RxBusBuilder.create(<CLASS>.class) is derived from the annotated functions parameter class. public void onEvent(Event event) will generate a RxBusBuilder.create(Event.class) code line
Examples
@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
}
TODO
just a idea so far
rethink annotation names
maybe enable auto subscribtion/unsubscription for classes with lifecycle via an additional annotation for the class itself (for Activity/Fragment/...). This could generate code that subscribes to the bus in the constructor/onCreate/onResume and unsubscribes them in the appropriate counter function
The text was updated successfully, but these errors were encountered:
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
@RxBusSubscribe
has following annotation fields:queuing
... defines theRxBusBuilder
swithQueuing
valuemode
... defines theRxBusBuilder
swithMode
valuekey
/keys
... defines theRxBusBuilder
swithKey
valueRxBusBuilder.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
/onResume
and unsubscribes them in the appropriate counter functionThe text was updated successfully, but these errors were encountered: