{"id":48680736,"url":"https://github.com/DevSrSouza/EventKt","last_synced_at":"2026-04-26T20:00:43.431Z","repository":{"id":103718464,"uuid":"222123103","full_name":"DevSrSouza/EventKt","owner":"DevSrSouza","description":"EventKt is a simple and lightweight kotlin multiplatform event bus library","archived":false,"fork":false,"pushed_at":"2020-10-15T22:56:59.000Z","size":125,"stargazers_count":57,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-27T23:26:12.747Z","etag":null,"topics":["android","android-library","eventbus","eventbus-library","kotlin","kotlin-coroutines","kotlin-multiplatform"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevSrSouza.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-11-16T15:58:11.000Z","updated_at":"2025-07-28T12:44:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"28349b33-f7d2-4bf2-8790-e5eb210b7bf7","html_url":"https://github.com/DevSrSouza/EventKt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DevSrSouza/EventKt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2FEventKt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2FEventKt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2FEventKt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2FEventKt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevSrSouza","download_url":"https://codeload.github.com/DevSrSouza/EventKt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevSrSouza%2FEventKt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32310804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T19:15:34.056Z","status":"ssl_error","status_checked_at":"2026-04-26T19:15:15.467Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","eventbus","eventbus-library","kotlin","kotlin-coroutines","kotlin-multiplatform"],"created_at":"2026-04-11T01:00:36.059Z","updated_at":"2026-04-26T20:00:43.424Z","avatar_url":"https://github.com/DevSrSouza.png","language":"Kotlin","funding_links":[],"categories":["进程间通信"],"sub_categories":["Spring Cloud框架"],"readme":"# EventKt\nEventKt is a simple and lightweight kotlin multiplatform event bus library.\n\nThe library uses Kotlin Coroutines Flow for provide you the events.\nAlso the library provide support for remote event publishing and listening, you can check more at the [remote section](#Remote).\n\n- [Principles](#Principles)\n- [Getting Started](#Getting-Started)\n- [Examples](#Examples)\n- [Remote](#Remote)\n\n## Principles\nThe EventKt is scoped based, this means that for you publish or listen for some event you need a [EventScope](/core/src/commonMain/kotlin/br/com/devsrsouza/eventkt/EventScope.kt).\nThe library provides a global scope [`GlobalEventScope`](/core/src/commonMain/kotlin/br/com/devsrsouza/eventkt/scopes/GlobalEventScope.kt).\n\n## Getting Started\n\n```groovy\nrepositories {\n    maven {\n        url = \"http://nexus.devsrsouza.com.br/repository/maven-public/\"\n    }\n}\n\ndependencies {\n    // multiplatform\n    implementation(\"br.com.devsrsouza.eventkt:eventkt-core:0.2.0-SNAPSHOT\")\n}\n```\n\n**JVM target**:\n`implementation(\"br.com.devsrsouza.eventkt:eventkt-core-jvm:0.2.0-SNAPSHOT\")`\n\n\n## Examples\n\n```kotlin\nimport br.com.devsrsouza.eventkt.scopes.GlobalEventScope\nimport br.com.devsrsouza.eventkt.listen\n\ndata class OnSomethingHappen(val withValue: String)\n\nGlobalEventScope.listen\u003cOnSomethingHappen\u003e()\n    .onEach { (withValue) -\u003e\n        println(\"Receive my event OnSomethingHappen was triggered with value: $withValue\")\n    }.launchIn(myCoroutineScope)\n\nGlobalEventScope.publish(OnSomethingHappen(\"Hello World!\"))\n```\n\n### Using with callback\n\n```kotlin\nimport br.com.devsrsouza.eventkt.scopes.GlobalEventScope\nimport br.com.devsrsouza.eventkt.scopes.asSimple\nimport br.com.devsrsouza.eventkt.listen\n\ndata class OnSomethingHappen(val withValue: String)\n\nSimpleGlobalEventScope.listen\u003cOnSomethingHappen\u003e(owner = this) { (withValue) -\u003e\n    println(\"Receive my event OnSomethingHappen was triggered with value: $withValue\")\n}\n\nSimpleGlobalEventScope.publish(OnSomethingHappen(\"Hello World!\"))\n```\n\n### Creating your own scope\n\n```kotlin\nimport br.com.devsrsouza.eventkt.scopes.LocalEventScope\nimport br.com.devsrsouza.eventkt.listen\n\ndata class OnSomethingLocallyHappen(val withValue: String)\n\nval yourScope = LocalEventScope()\n\nyourScope.listen\u003cOnSomethingLocallyHappen\u003e()\n    .onEach { (withValue) -\u003e\n        println(\"Receive my event OnSomethingLocallyHappen was triggered with value: $withValue\")\n    }.launchIn(myCoroutineScope)\n\nyourScope.publish(OnSomethingHappen(\"Hello Local World!\"))\n```\n\n### Listen in your coroutine scope\n\n```kotlin\nimport br.com.devsrsouza.eventkt.scopes.GlobalEventScope\nimport br.com.devsrsouza.eventkt.scopes.asSimple\nimport br.com.devsrsouza.eventkt.listen\n\nval singleThreadContext = newSingleThreadContext(\"EventReceiverThread\")\nval myCoroutineScope = CoroutineScope(singleThreadContext)\n\ndata class OnSomethingHappen()\n\nval simpleEventScope = GlobalEventScope.asSimple()\n\nsimpleEventScope.listen\u003cOnSomethingHappen\u003e(owner = this, coroutineScope = myCoroutineScope) { (withValue) -\u003e\n    println(\"Receive my event in thread: ${Thread.currentThread().name}\")\n}\n\nGlobalEventScope.publish(OnSomethingHappen())\n```\n\nIn Android you could receive events directly in the Main Thread (UI Thread) using simples as well.\n``SimpleGlobalEventScope.listen\u003cOnSomethingHappen\u003e(owner = this, coroutineScope = viewLifecycleOwner.lifecycleScope) {}``\n\n\n### Unregistering callback listener\nWhen using simple scope you should always **unregister** your owners on disable/destroy/stop a object that listen, like a Activity/Fragment/Service on Android\n\n```kotlin\nimport br.com.devsrsouza.eventkt.scopes.asSimple\n\nsimpleEventScope.unregisterOwner(owner = this)\n```\n\n### withOwner extension\n\n```kotlin\nimport br.com.devsrsouza.eventkt.scopes.asSimple\n\nSimpleGlobalEventScope.withOwner(this) {\n    listen\u003cOnSomethingHappen\u003e {\n        println(\"Yeah!\")\n    }\n}\n\n// unregistering\nSimpleGlobalEventScope.unregister(this)\n```\n\n\n### Combining EventScopes\n\n```kotlin\nval combinedScope: EventScope = LocalEventScope() + RedisEventScope()\n```\n\n## Remote\n\nEventKt is design to be used with Remote event publisher, such as Redis Pub/Sub, WebsSocket, Kafka, MQTT, AMQP etc.\n\n### Encoders\n\nRemote event listen and publish require to your class/object to enconded and decoded, for this reason, you will need a encoder.\nEventKt provides a [Kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) encoder implementation.\n\n```kotlin\ndependencies {\n    implementation(\"br.com.devsrsouza.eventkt:eventkt-remote-encoder-serialization:0.2.0-SNAPSHOT\")\n}\n``` \n\n### Supported clients\n\n| Client | Package |\n| -------- | ------- |\n| Jedis/Redis (jvm) | `br.com.devsrsouza.eventkt:eventkt-remote-jvm-jedis:0.2.0-SNAPSHOT` |\n| RabbitMQ/AMQP (jvm) | `br.com.devsrsouza.eventkt:eventkt-remote-jvm-rabbitmq:0.2.0-SNAPSHOT` |\n| Eclipse Paho/MQTT (jvm) | `br.com.devsrsouza.eventkt:eventkt-remote-jvm-paho:0.2.0-SNAPSHOT` |\n\n### Redis example\nThe project ships a [Jedis Redis Client](https://github.com/xetorthio/jedis) implementation (jvm only).\nThe recommendation is to use [Kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) encoder, in case you use it, \nyou will need make your events `@Serializable`.\n\n```kotlin\ndependencies {\n    implementation(\"br.com.devsrsouza.eventkt:eventkt-remote-jvm-jedis:0.2.0-SNAPSHOT\")\n\n    // encoder\n    implementation(\"br.com.devsrsouza.eventkt:eventkt-remote-encoder-serialization:0.2.0-SNAPSHOT\")\n}\n```\n\n#### Usage\n\n```kotlin\nval subscribe = Jedis(\"127.0.0.1\").apply { connect() }\nval publisher = Jedis(\"127.0.0.1\").apply { connect() }\n\nval redisScope = JedisEventScope(\n    StringSerializationRemoteEncoder(Json),\n    subscribe,\n    publisher,\n    channelName = \"MyProjectChannelName\"\n)\n```\n\nWith this scope you can publish and listen to events from remote instances.\n\n```kotlin\n@Serializable\ndata class YourEventClass(val x: String)\n\nredisScope.listen\u003cYourEventClass\u003e()\n    .onEach { println(it) }\n    .launchIn(GlobalScope)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDevSrSouza%2FEventKt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDevSrSouza%2FEventKt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDevSrSouza%2FEventKt/lists"}