Infinum Android Talks #15 - Garfield Android Studio Plugin - Be Smart, Be Lazy
Infinum Android Talks #02 - EventBus
-
Upload
infinum-ltd -
Category
Technology
-
view
765 -
download
2
description
Transcript of Infinum Android Talks #02 - EventBus
EventBus Dino Kovač
• simple communication between parts of the app
• avoid spaghetti code • easy way to notify the user when
he loses network connectivity
Motivation
Init
• add a maven dependency or add as a jar • … and you’re done :)
compile ‘de.greenrobot:eventbus:2.2.0@jar’
• register subscribers
•EventBus.getDefault().register(object); !• post events
•EventBus.getDefault().post(new Object()); !• handle events in onEvent methods
•public void onEvent(Object o) { … }
Usage
Register for events
Post events
Handle events
Threads, Crouton
• sticky events • registerSticky(object); postSticky(new Object());
!• async event delivery
• onEventAsync(Object o) { … } !• multiple EventBus buses
You need more?
https://github.com/greenrobot/EventBus !
https://github.com/keyboardsurfer/Crouton !
https://github.com/reisub/eventbus-example
Links