Skip to content

danylo-pavenko/coroutines-event-pipe

Repository files navigation

Library EventPipe similar to EventBus

Android Arsenal

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.

About

Library similar to EventBus, but use Kotlin Coroutines Channel as a provider of Event.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages