### EventKt EventScope Interface and Usage (Kotlin) Source: https://context7.com/devsrsouza/eventkt/llms.txt Demonstrates the core EventScope interface for publishing and listening to typed events using Kotlin Flow. Includes examples of using the reified extension function for cleaner syntax. Events are received as a Flow and can be processed with operators like onEach and launched in a CoroutineScope. ```Kotlin import br.com.devsrsouza.eventkt.EventScope import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.launchIn import kotlin.reflect.KClass // EventScope interface definition interface EventScope : CoroutineScope { // Publish a new event fun publish(any: Any) // Receives events as Flow from the given type fun listen(type: KClass): Flow } // Using the reified extension function for cleaner syntax data class UserLoggedIn(val userId: String, val timestamp: Long) // Assume eventScope and myCoroutineScope are defined elsewhere // val eventScope: EventScope = ... // val myCoroutineScope: CoroutineScope = ... // Listen for events (returns a Flow) // val eventFlow: Flow = eventScope.listen() // eventFlow // .onEach { event -> // println("User ${event.userId} logged in at ${event.timestamp}") // } // .launchIn(myCoroutineScope) // Publish an event // eventScope.publish(UserLoggedIn("user123", System.currentTimeMillis())) ``` -------------------------------- ### Publish and Listen to Events Source: https://github.com/devsrsouza/eventkt/blob/master/README.md Demonstrates how to define an event data class, listen for events using a GlobalEventScope, and publish events to that scope. ```kotlin import br.com.devsrsouza.eventkt.scopes.GlobalEventScope import br.com.devsrsouza.eventkt.listen data class OnSomethingHappen(val withValue: String) GlobalEventScope.listen() .onEach { (withValue) -> println("Receive my event OnSomethingHappen was triggered with value: $withValue") }.launchIn(myCoroutineScope) GlobalEventScope.publish(OnSomethingHappen("Hello World!")) ``` -------------------------------- ### MQTT Event Distribution with MqttEventScope Source: https://context7.com/devsrsouza/eventkt/llms.txt Demonstrates how to use MqttEventScope to publish and subscribe to events over MQTT. It requires Eclipse Paho client and Kotlinx.serialization for encoding. Events are serialized using CBOR and published to topics derived from event types. ```kotlin import br.com.devsrsouza.eventkt.jvm.paho.MqttEventScope import br.com.devsrsouza.eventkt.remote.encoder.serialization.BinarySerializationRemoteEncoder import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.serialization.Serializable import kotlinx.serialization.cbor.Cbor import org.eclipse.paho.client.mqttv3.MqttAsyncClient import org.eclipse.paho.client.mqttv3.MqttConnectOptions import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence @Serializable data class SensorReadingEvent(val sensorId: String, val value: Double) // Create MQTT client val mqttClient = MqttAsyncClient( "tcp://localhost:1883", "eventkt-client-${System.currentTimeMillis()}", MemoryPersistence() ) // Connect to broker val options = MqttConnectOptions().apply { isCleanSession = true isAutomaticReconnect = true } mqttClient.connect(options).waitForCompletion() // Create MQTT event scope val mqttScope = MqttEventScope( enconder = BinarySerializationRemoteEncoder(Cbor), mqttClient = mqttClient ) // Listen for events - automatically subscribes to topic mqttScope.listen() .onEach { event -> println("Sensor ${event.sensorId}: ${event.value}") } .launchIn(GlobalScope) // Publish events - uses QoS 0 (fire and forget) mqttScope.publish(SensorReadingEvent("temp-sensor-1", 23.5)) ``` -------------------------------- ### Initialize JedisEventScope for Redis Communication (Kotlin) Source: https://github.com/devsrsouza/eventkt/blob/master/README.md Demonstrates how to initialize the JedisEventScope for publishing and subscribing to events over Redis. It requires Jedis client instances and a serialization encoder. ```kotlin val subscribe = Jedis("127.0.0.1").apply { connect() } val publisher = Jedis("127.0.0.1").apply { connect() } val redisScope = JedisEventScope( StringSerializationRemoteEncoder(Json), subscribe, publisher, channelName = "MyProjectChannelName" ) ``` -------------------------------- ### Publish and Listen to Events with JedisEventScope (Kotlin) Source: https://github.com/devsrsouza/eventkt/blob/master/README.md Shows how to define a serializable event class and then use the JedisEventScope to listen for and process incoming events. Events must be marked with @Serializable. ```kotlin @Serializable data class YourEventClass(val x: String) redisScope.listen() .onEach { println(it) } .launchIn(GlobalScope) ``` -------------------------------- ### GlobalEventScope for Application-Wide Events (Kotlin) Source: https://context7.com/devsrsouza/eventkt/llms.txt Shows how to use GlobalEventScope, a singleton for application-wide event handling. Events published to GlobalEventScope are accessible throughout the entire application. It internally delegates to a LocalEventScope. ```Kotlin import br.com.devsrsouza.eventkt.scopes.GlobalEventScope import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach data class OnSomethingHappen(val withValue: String) val myCoroutineScope = CoroutineScope(Dispatchers.Default) // Listen for events globally GlobalEventScope.listen() .onEach { (withValue) -> println("Received event with value: $withValue") } .launchIn(myCoroutineScope) // Publish events globally GlobalEventScope.publish(OnSomethingHappen("Hello World!")) // Expected Output: Received event with value: Hello World! ``` -------------------------------- ### Configure EventKt Dependencies Source: https://github.com/devsrsouza/eventkt/blob/master/README.md Add the EventKt library to your Gradle project. This includes the core multiplatform dependency and JVM-specific targets. ```groovy repositories { maven { url = "http://nexus.devsrsouza.com.br/repository/maven-public/" } } dependencies { implementation("br.com.devsrsouza.eventkt:eventkt-core:0.2.0-SNAPSHOT") } ``` ```kotlin implementation("br.com.devsrsouza.eventkt:eventkt-core-jvm:0.2.0-SNAPSHOT") ``` -------------------------------- ### Add EventKT Redis Dependencies (Kotlin) Source: https://github.com/devsrsouza/eventkt/blob/master/README.md This snippet shows the Gradle dependencies required to use the EventKT Redis client (Jedis) and the Kotlinx.serialization encoder for JVM projects. ```kotlin dependencies { implementation("br.com.devsrsouza.eventkt:eventkt-remote-jvm-jedis:0.2.0-SNAPSHOT") // encoder implementation("br.com.devsrsouza.eventkt:eventkt-remote-encoder-serialization:0.2.0-SNAPSHOT") } ``` -------------------------------- ### EventKt Gradle Dependency Configuration Source: https://context7.com/devsrsouza/eventkt/llms.txt Provides the Gradle configuration to include EventKt modules in your project. It specifies the custom Maven repository and lists the dependencies for core modules, Kotlinx.serialization encoders, and various remote client integrations (Jedis, RabbitMQ, MQTT). ```gradle // build.gradle.kts repositories { maven { url = uri("http://nexus.devsrsouza.com.br/repository/maven-public/") } } dependencies { // Core module - required for all usage // Multiplatform implementation("br.com.devsrsouza.eventkt:eventkt-core:0.2.0-SNAPSHOT") // JVM only implementation("br.com.devsrsouza.eventkt:eventkt-core-jvm:0.2.0-SNAPSHOT") // Kotlinx.serialization encoder - required for remote events implementation("br.com.devsrsouza.eventkt:eventkt-remote-encoder-serialization:0.2.0-SNAPSHOT") // Remote clients (JVM only) - pick the ones you need // Redis via Jedis implementation("br.com.devsrsouza.eventkt:eventkt-remote-jvm-jedis:0.2.0-SNAPSHOT") // RabbitMQ via AMQP implementation("br.com.devsrsouza.eventkt:eventkt-remote-jvm-rabbitmq:0.2.0-SNAPSHOT") // MQTT via Eclipse Paho implementation("br.com.devsrsouza.eventkt:eventkt-remote-jvm-paho:0.2.0-SNAPSHOT") } ``` -------------------------------- ### Redis Event Handling with JedisEventScope Source: https://context7.com/devsrsouza/eventkt/llms.txt Implements distributed event handling using Redis Pub/Sub. Events are serialized and transmitted through Redis channels. Requires Jedis client and Kotlinx.serialization. Events must be @Serializable. ```kotlin import br.com.devsrsouza.eventkt.jvm.jedis.JedisEventScope import br.com.devsrsouza.eventkt.remote.encoder.serialization.StringSerializationRemoteEncoder import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json import redis.clients.jedis.Jedis // Events MUST be @Serializable for remote transmission @Serializable data class UserCreatedEvent(val userId: String, val email: String) @Serializable data class OrderPlacedEvent(val orderId: String, val amount: Double) // Redis requires separate connections for subscribe and publish val subscribeJedis = Jedis("127.0.0.1", 6379).apply { connect() } val publisherJedis = Jedis("127.0.0.1", 6379).apply { connect() } // Create Redis event scope with JSON serialization val redisScope = JedisEventScope( enconder = StringSerializationRemoteEncoder(Json), subscribeJedis = subscribeJedis, publisherJedis = publisherJedis, channelName = "my-app-events" // Custom channel name ) // Listen for events from any connected instance redisScope.listen() .onEach { event -> println("User created: ${event.userId} - ${event.email}") } .launchIn(GlobalScope) redisScope.listen() .onEach { event -> println("Order placed: ${event.orderId} for $${event.amount}") } .launchIn(GlobalScope) // Publish events - received by all listening instances redisScope.publish(UserCreatedEvent("user-123", "user@example.com")) redisScope.publish(OrderPlacedEvent("order-456", 99.99)) ``` -------------------------------- ### Batch Register Listeners with withOwner DSL Source: https://context7.com/devsrsouza/eventkt/llms.txt Utilizes the withOwner extension to register multiple event listeners under a single owner. This simplifies cleanup logic by allowing a single unregister call to remove all associated listeners. ```kotlin import br.com.devsrsouza.eventkt.scopes.SimpleGlobalEventScope import br.com.devsrsouza.eventkt.extensions.withOwner import br.com.devsrsouza.eventkt.extensions.listen import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers data class OnSomethingHappen(val message: String) data class OnUserAction(val action: String) class MyActivity { private val coroutineScope = CoroutineScope(Dispatchers.Main) fun onCreate() { SimpleGlobalEventScope.withOwner(this) { listen(coroutineScope) { event -> println("Something happened: ${event.message}") } listen(coroutineScope) { event -> println("User action: ${event.action}") } } } fun onDestroy() { SimpleGlobalEventScope.unregister(this) } } ``` -------------------------------- ### RabbitMQ Event Handling with RabbitMQEventScope Source: https://context7.com/devsrsouza/eventkt/llms.txt Implements distributed event handling using RabbitMQ message queues. Events are published to queues named by their type unique ID. Requires RabbitMQ client and Kotlinx.serialization with Protobuf. ```kotlin import br.com.devsrsouza.eventkt.jvm.rabbitmq.RabbitMQEventScope import br.com.devsrsouza.eventkt.remote.encoder.serialization.BinarySerializationRemoteEncoder import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.serialization.Serializable import kotlinx.serialization.protobuf.ProtoBuf import com.rabbitmq.client.ConnectionFactory @Serializable data class TaskCreatedEvent(val taskId: String, val title: String) // Create RabbitMQ connection val factory = ConnectionFactory().apply { host = "localhost" port = 5672 username = "guest" password = "guest" } val connection = factory.newConnection() val channel = connection.createChannel() // Create RabbitMQ event scope with binary (ProtoBuf) encoding val rabbitScope = RabbitMQEventScope( enconder = BinarySerializationRemoteEncoder(ProtoBuf), channel = channel ) // Listen for events - automatically declares and consumes from queue rabbitScope.listen() .onEach { event -> println("Task created: ${event.taskId} - ${event.title}") } .launchIn(GlobalScope) // Publish events - automatically declares queue and publishes rabbitScope.publish(TaskCreatedEvent("task-789", "Implement feature X")) ``` -------------------------------- ### Creating and Using Custom Scopes Source: https://github.com/devsrsouza/eventkt/blob/master/README.md Create a local event scope to isolate events within specific components or application modules. ```kotlin import br.com.devsrsouza.eventkt.scopes.LocalEventScope import br.com.devsrsouza.eventkt.listen data class OnSomethingLocallyHappen(val withValue: String) val yourScope = LocalEventScope() yourScope.listen() .onEach { (withValue) -> println("Receive my event OnSomethingLocallyHappen was triggered with value: $withValue") }.launchIn(myCoroutineScope) yourScope.publish(OnSomethingHappen("Hello Local World!")) ``` -------------------------------- ### Combining Event Scopes Source: https://github.com/devsrsouza/eventkt/blob/master/README.md Combine multiple event scopes into a single instance to aggregate event streams from different sources. ```kotlin val combinedScope: EventScope = LocalEventScope() + RedisEventScope() ``` -------------------------------- ### LocalEventScope for Isolated Event Handling (Kotlin) Source: https://context7.com/devsrsouza/eventkt/llms.txt Demonstrates the use of LocalEventScope for creating isolated event channels. This scope is ideal for scenarios where event handling should not interfere with other scopes. It supports type-safe filtering, ensuring only matching event types are received by listeners. ```Kotlin import br.com.devsrsouza.eventkt.scopes.LocalEventScope import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach data class OnSomethingLocallyHappen(val withValue: String) data class TestDataClass(val x: String, val y: Int) // Create an isolated event scope val yourScope = LocalEventScope() val myCoroutineScope = CoroutineScope(Dispatchers.Default) // Listen for events within this scope only yourScope.listen() .onEach { (withValue) -> println("Local event received: $withValue") } .launchIn(myCoroutineScope) // Type-safe filtering - only matching types are received yourScope.listen() .onEach { data -> println("TestDataClass received: x=${data.x}, y=${data.y}") } .launchIn(myCoroutineScope) // Publish to the local scope yourScope.publish(OnSomethingLocallyHappen("Hello Local World!")) yourScope.publish(TestDataClass("test x", 5)) yourScope.publish("This string won't trigger TestDataClass listener") // Expected Output: // Local event received: Hello Local World! // TestDataClass received: x=test x, y=5 ``` -------------------------------- ### GlobalEventScope Source: https://context7.com/devsrsouza/eventkt/llms.txt A singleton event scope for application-wide event handling. It's ideal for events accessible throughout the entire application. ```APIDOC ## GlobalEventScope ### Description `GlobalEventScope` is a singleton event scope for application-wide event handling. It delegates to a LocalEventScope internally and is ideal for events that need to be accessible throughout the entire application. ### Method N/A (Singleton Object) ### Endpoint N/A (Singleton Object) ### Parameters N/A (Singleton Object) ### Request Example N/A (Singleton Object) ### Response N/A (Singleton Object) ### Code Example ```kotlin import br.com.devsrsouza.eventkt.scopes.GlobalEventScope import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach data class OnSomethingHappen(val withValue: String) val myCoroutineScope = CoroutineScope(Dispatchers.Default) // Listen for events globally GlobalEventScope.listen() .onEach { (withValue) -> println("Received event with value: $withValue") } .launchIn(myCoroutineScope) // Publish events globally GlobalEventScope.publish(OnSomethingHappen("Hello World!")) // Output: Received event with value: Hello World! ``` ``` -------------------------------- ### Using Simple Callback Scopes Source: https://github.com/devsrsouza/eventkt/blob/master/README.md Utilize SimpleGlobalEventScope for callback-based event handling, which is useful for Android lifecycle-bound components. ```kotlin import br.com.devsrsouza.eventkt.scopes.GlobalEventScope import br.com.devsrsouza.eventkt.scopes.asSimple import br.com.devsrsouza.eventkt.listen data class OnSomethingHappen(val withValue: String) SimpleGlobalEventScope.listen(owner = this) { (withValue) -> println("Receive my event OnSomethingHappen was triggered with value: $withValue") } SimpleGlobalEventScope.publish(OnSomethingHappen("Hello World!")) ``` -------------------------------- ### Manage Lifecycle-Aware Listeners with SimpleEventScope Source: https://context7.com/devsrsouza/eventkt/llms.txt Demonstrates how to use SimpleEventScope to register and unregister event listeners tied to an object owner. This pattern is essential for preventing memory leaks in Android components by ensuring listeners are cleaned up during destruction. ```kotlin import br.com.devsrsouza.eventkt.scopes.GlobalEventScope import br.com.devsrsouza.eventkt.scopes.SimpleGlobalEventScope import br.com.devsrsouza.eventkt.scopes.asSimple import br.com.devsrsouza.eventkt.scopes.listen import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers data class OnSomethingHappen(val withValue: String) val simpleScope = SimpleGlobalEventScope val customSimpleScope = GlobalEventScope.asSimple() class MyComponent { private val coroutineScope = CoroutineScope(Dispatchers.Main) fun onCreate() { simpleScope.listen( owner = this, coroutineScope = coroutineScope ) { (withValue) -> println("Callback received: $withValue") } } fun onDestroy() { simpleScope.unregister(this) } } SimpleGlobalEventScope.publish(OnSomethingHappen("Hello World!")) ``` -------------------------------- ### Merge Event Scopes with CombinedEventScope Source: https://context7.com/devsrsouza/eventkt/llms.txt Shows how to merge multiple EventScope instances using the + operator. Events published to the combined scope propagate to all underlying scopes, and listeners on the combined scope receive events from all merged sources. ```kotlin import br.com.devsrsouza.eventkt.EventScope import br.com.devsrsouza.eventkt.scopes.LocalEventScope import br.com.devsrsouza.eventkt.scopes.CombinedEventScope import br.com.devsrsouza.eventkt.listen import br.com.devsrsouza.eventkt.plus import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach data class SharedEvent(val data: String) val localScope = LocalEventScope() val anotherScope = LocalEventScope() val combinedScope: EventScope = localScope + anotherScope combinedScope.listen() .onEach { event -> println("Received from combined: ${event.data}") } .launchIn(myCoroutineScope) combinedScope.publish(SharedEvent("Hello from combined!")) localScope.publish(SharedEvent("Direct to local")) anotherScope.publish(SharedEvent("Direct to another")) ``` -------------------------------- ### EventScope Interface Source: https://context7.com/devsrsouza/eventkt/llms.txt The core interface for publishing and listening to events. It extends CoroutineScope and provides type-safe event streaming. ```APIDOC ## EventScope Interface ### Description The `EventScope` interface is the foundation of EventKt, defining the contract for publishing and listening to events. It extends CoroutineScope and provides type-safe event streaming through Kotlin Flow. ### Method N/A (Interface Definition) ### Endpoint N/A (Interface Definition) ### Parameters N/A (Interface Definition) ### Request Example N/A (Interface Definition) ### Response N/A (Interface Definition) ### Code Example ```kotlin import br.com.devsrsouza.eventkt.EventScope import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.launchIn // EventScope interface definition interface EventScope : CoroutineScope { // Publish a new event fun publish(any: Any) // Receives events as Flow from the given type fun listen(type: KClass): Flow } // Using the reified extension function for cleaner syntax data class UserLoggedIn(val userId: String, val timestamp: Long) // Listen for events (returns a Flow) val eventFlow: Flow = eventScope.listen() eventFlow .onEach { event -> println("User ${event.userId} logged in at ${event.timestamp}") } .launchIn(myCoroutineScope) // Publish an event eventScope.publish(UserLoggedIn("user123", System.currentTimeMillis())) ``` ``` -------------------------------- ### LocalEventScope Source: https://context7.com/devsrsouza/eventkt/llms.txt Provides an isolated event scope for localized event handling, ensuring separate event channels. ```APIDOC ## LocalEventScope ### Description `LocalEventScope` provides an isolated event scope for localized event handling. Use this when you need separate event channels that don't interfere with global or other local scopes. ### Method N/A (Class Instantiation) ### Endpoint N/A (Class Instantiation) ### Parameters N/A (Class Instantiation) ### Request Example N/A (Class Instantiation) ### Response N/A (Class Instantiation) ### Code Example ```kotlin import br.com.devsrsouza.eventkt.scopes.LocalEventScope import br.com.devsrsouza.eventkt.listen import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach data class OnSomethingLocallyHappen(val withValue: String) data class TestDataClass(val x: String, val y: Int) // Create an isolated event scope val yourScope = LocalEventScope() val myCoroutineScope = CoroutineScope(Dispatchers.Default) // Listen for events within this scope only yourScope.listen() .onEach { (withValue) -> println("Local event received: $withValue") } .launchIn(myCoroutineScope) // Type-safe filtering - only matching types are received yourScope.listen() .onEach { data -> println("TestDataClass received: x=${data.x}, y=${data.y}") } .launchIn(myCoroutineScope) // Publish to the local scope yourScope.publish(OnSomethingLocallyHappen("Hello Local World!")) yourScope.publish(TestDataClass("test x", 5)) yourScope.publish("This string won't trigger TestDataClass listener") // Output: // Local event received: Hello Local World! // TestDataClass received: x=test x, y=5 ``` ``` -------------------------------- ### RemoteEncoder Interface for Event Serialization Source: https://context7.com/devsrsouza/eventkt/llms.txt Defines the RemoteEncoder interface for serializing and deserializing events for remote transmission. Includes implementations for JSON (StringSerializationRemoteEncoder) and Protobuf (BinarySerializationRemoteEncoder) using Kotlinx.serialization. This is crucial for different remote scopes like Redis and RabbitMQ. ```kotlin import br.com.devsrsouza.eventkt.remote.RemoteEncoder import br.com.devsrsouza.eventkt.remote.RemoteDecodeResult import br.com.devsrsouza.eventkt.remote.ListenerTypeSet import br.com.devsrsouza.eventkt.remote.encoder.serialization.StringSerializationRemoteEncoder import br.com.devsrsouza.eventkt.remote.encoder.serialization.BinarySerializationRemoteEncoder import kotlinx.serialization.json.Json import kotlinx.serialization.protobuf.ProtoBuf import kotlin.reflect.KClass // RemoteEncoder interface definition interface RemoteEncoder { // Encode event instance to transmission format fun encode(event: Any, listenTypes: ListenerTypeSet): T // Decode transmission format back to event instance fun decode(value: T, listenTypes: ListenerTypeSet): RemoteDecodeResult // Get unique identifier for event type (e.g., fully qualified name) fun typeUniqueId(eventType: KClass, listenTypes: ListenerTypeSet): String } // String-based encoder (JSON) - for Redis/Jedis val jsonEncoder = StringSerializationRemoteEncoder(Json) // Custom JSON configuration val customJsonEncoder = StringSerializationRemoteEncoder( Json { ignoreUnknownKeys = true encodeDefaults = true } ) // Binary encoder (ProtoBuf) - for RabbitMQ/MQTT val protobufEncoder = BinarySerializationRemoteEncoder(ProtoBuf) // Usage with remote scope val redisScope = JedisEventScope( enconder = jsonEncoder, subscribeJedis = subscribeJedis, publisherJedis = publisherJedis ) ``` -------------------------------- ### Managing Listener Lifecycle Source: https://github.com/devsrsouza/eventkt/blob/master/README.md Unregister listeners when they are no longer needed to prevent memory leaks, particularly in Android Activity or Fragment lifecycles. ```kotlin import br.com.devsrsouza.eventkt.scopes.asSimple simpleEventScope.unregisterOwner(owner = this) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.