observer
Creates a new observer for subscribing to its events.
e.g. (Kotlin)
MyEvent.THIS.observer { data ->
updateNotification(data.formatBandwidth())
}
e.g. (Java)
MyEvent.THAT.INSTANCE.observer(data -> {
updateNotification(formatBandwidth(data));
});
Parameters
The callback to pass event data to
Creates a new observer with the provided tag for subscribing to its events.
This is useful for lifecycle aware components, all of which can be removed with a single call using the tag upon component destruction.
e.g. (Kotlin)
MyEvent.THIS.observer("my service") { data ->
updateNotification(data.formatBandwidth())
}
e.g. (Java)
MyEvent.THAT.INSTANCE.observer("my service", data -> {
updateNotification(formatBandwidth(data));
});
Parameters
A string to help grouping/identifying observer(s)
The callback to pass event data to
Creates a new observer with the provided tag and executor for subscribing to its events.
This is useful for lifecycle aware components, all of which can be removed with a single call using the tag upon component destruction.
e.g. (Kotlin)
MyEvent.THIS.observer(null, OnEvent.Executor.Main) { data ->
updateNotification(data.formatBandwidth())
}
e.g. (Java)
MyEvent.THAT.INSTANCE.observer("my tag", null, data -> {
updateNotification(formatBandwidth(data));
});
Parameters
A string to help grouping/identifying observer(s)
The thread context in which onEvent will be invoked in. If null, the default passed to Observer.notify from the Event processor implementation will be utilized.
The callback to pass event data to.