Library EventPipe similar to EventBus
Old version
This library base on Kotlin Coroutines Channel.
New version
Version 2.0 and next based on Kotlin Coroutines SharedFlow
1. Implementation by Gradle.
implementation 'com.github.Daniil-Pavenko:coroutines-event-pipe:2.0.0'
2. Methods for using:
- Register event class:
EventPipe.registerEvent(
eventClass: Class<T>,
contextName: String = GLOBAL_CONTEXT, // default
eventDispatcher: CoroutineDispatcher = Dispatchers.Main, // default
eventCallback: suspend (event: T) -> Unit
)
- And unregister into
onDestroy
oronStop
by your logic:
EventPipe.unregisterAllEvents() - for all Events
or
EventPipe.unregisterByContext(contextName: String)
- Send event:
EventPipe.send(event: Any, delaySend: Long = 0)
3. Configure proguard rules.
- Add package of lib.
- Add package with Event classes.
#EventPipe
-keep class com.dansdev.libeventpipe.** { *; }