Tunnel is Pub-Sub library inspired from NYBus It made with Kotlin Coroutines, Channes and Flow
-
Tunnel-Compiler is annotation procesor that processes
Subsribe
annotation in Client Code and based on that creates Target Map (Message Delivery Map). Target Map is generated and perisisted asTunnelMap
class. -
TunnelMap
is used by Tunnel module to post the message object to correctSubscribed
target
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency. (latest_tag = v0.0.1 )
dependencies {
implementation 'com.github.RotBolt:Tunnel:latest_tag'
kapt 'com.github.RotBolt:Tunnel-Compiler:latest_tag'
}
- Register the class
Tunnel.get().register(RegistryClass(this))
- Create method to receive the posted messages
@Subscribe(dispatcherType = DispatcherType.IO, channelIds = ["CHANNEL_1", "CHANNEL_2"])
fun onEvent(name: Bundle) {
}
- Post the message object
Tunnel.get().post(TunnelMessage(Bundle().apply {
putString("PUI", "Hola")
}), "CHANNEL_1")
- You can create separate channels as per need and can subscribe to multiple channels
- Supported Dispatchers (Uses Coroutine Dispatcher)
- IO
- Main
- Computation
- Post
- SingleThreadExecutor
- Unit Tests
- Error checks for invalid method
- Support for logging