Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nort3x/Event4k
eventbus library for kotlin multiplatform
https://github.com/nort3x/Event4k
event4k eventbus kotlin multiplatform-kotlin-library
Last synced: 6 days ago
JSON representation
eventbus library for kotlin multiplatform
- Host: GitHub
- URL: https://github.com/nort3x/Event4k
- Owner: nort3x
- License: mit
- Created: 2023-01-12T01:09:51.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-05-11T10:58:02.000Z (over 1 year ago)
- Last Synced: 2024-08-02T09:26:51.748Z (3 months ago)
- Topics: event4k, eventbus, kotlin, multiplatform-kotlin-library
- Language: Kotlin
- Homepage:
- Size: 71.3 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-kotlin-multiplatform - Event4k - MultiPlatform Kotlin EventBus library - simple, bidirectional, concurrent. (Libraries / Utility)
README
# Event4K
### Why it exist
because I needed a quick multiplatform event bus library and couldn't find
something which respect: `"Do One Thing and Do It Well"`
(it does one thing but doing it well is to be tested)features:
* only 3 methods and 3 overloads, `register`, `publish`, `consumeOnce`
* `RegisterHook` to deRegister, number of invokes, last value, awaitNextInvoke, etc...
* `publisher` will receive return value of registrations (bi-directional)
* multiplatform (**common**)
### Usage```kotlin
val event4k = Event4k()fun main() {
val hook1 = event4k.register("key") { event: Type, hook: RegisterHook ->
// handle event and possibly send something for publisher
// hook is passed for per invoke inspection
"handled"
}// type overload, key is computed from Type
val hook2 = even4k.register { e: Type, _ ->
// ...
}//....
// Map
val registersReturnMap = event4k.publish("key", Type("event"))
// type overload
val registersReturnMap1 = event4k.publish(Type("event"))val resultOfComputationBlocking = event4k.consumeOnce { e: Type, _ ->
return doSomethingOn(e) // and deRegister
}
}
```### Download
maven:
```xml
jitpack.io
https://jitpack.io
com.github.nort3x
event4k
VERSION
```
gradle:
```groovy
// add jitpack
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}// add dependency
// probably in commonMain
dependencies {
implementation 'com.github.nort3x:event4k:VERSION'
}```
gradle(kotlin):
```kotlin
allprojects {
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}// add dependency
// probably in commonMain
dependencies {
implementation("com.github.nort3x:event4k:VERSION")
}
```### Licence
**MIT**Copyright 2023 , Human Ardaki
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.