Coroutines Event Pipe

Additional

Language
Kotlin
Version
N/A
Created
Jul 26, 2019
Updated
Apr 5, 2023 (Retired)
Owner
Danylo Pavenko (danylo-pavenko)
Contributor
Danylo Pavenko (danylo-pavenko)
1
Activity
Badge
Generate
Download
Source code

Advertisement

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 or onStop 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.** { *; }

Please, starred lib, if you like it.