KDispatcher alternatives and similar libraries
Based on the "Misc" category.
Alternatively, view KDispatcher alternatives based on common mentions on social networks and blogs.
-
jclasslib
jclasslib bytecode editor is a tool that visualizes all aspects of compiled Java class files and the contained bytecode. -
kotlin-logging
Lightweight Multiplatform logging framework for Kotlin. A convenient and performant logging facade. -
lingua
The most accurate natural language detection library for Java and the JVM, suitable for long and short text alike -
Kotlift
DISCONTINUED. Kotlift is the first source-to-source language transpiler from Kotlin to Swift -
Humanizer.jvm
Humanizer.jvm meets all your jvm needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities. -
klutter
A mix of random small libraries for Kotlin, the smallest reside here until big enough for their own repository. -
kassava
This library provides some useful kotlin extension functions for implementing toString(), hashCode() and equals() without all of the boilerplate. -
solr-undertow
Solr / SolrCloud running in high performance server - tiny, fast startup, simple to configure, easy deployment without an application server. -
SimpleDNN
SimpleDNN is a machine learning lightweight open-source library written in Kotlin designed to support relevant neural network architectures in natural language processing tasks -
kotlin-futures
A collections of extension functions to make the JVM Future, CompletableFuture, ListenableFuture API more functional and Kotlin like. -
kasechange
๐ซ๐๐ข๐ ฟ Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case -
PrimeCalendar
PrimeCalendar provides all of the java.util.Calendar functionalities for Persian, Hijri, and ... dates. It is also possible to convert dates to each other.
WorkOS - The modern identity platform for B2B SaaS
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of KDispatcher or a related project?
README
KDispatcher is a Kotlin EventDispatcher
This is light-weight event dispatcher based on KOTLIN
priority: Int? = null
to subscribe function for sorting- Inline function Included
You can subscribe on event by calling:
val EVENT_CALL_ONE = "simple_event_name"
val eventListener = ::eventHandler
val priority = 1
KDispatcher.subscribe(EVENT_CALL_ONE, eventListener, priority)
where:
- EVENT_CALL_ONE - simple event type
- eventListener - function listener for event
- priority - the priority to sort calling functions
/**
* notif:Notification<T:Any> - event holder object that store
* data:T? = null - can be any type of data
* eventName:String? = null - current event type
* cause u may have more then one EVENT_TYPE for current event listener
*/
fun eventHandler(notif:Notification<Any>){
when(notif.eventName){
EVENT_CALL_ONE -> println("FIRST EVENT")
}
}
Of course u can simpe call the event for all listeners by
val test:MyTestClass = MyTestClass()
KDispatcher.call(EVENT_CALL_ONE, test)
Don't forget to unsubscribe your listeners when u dont need it anymore.
KDispatcher.unsubscribe(EVENT_CALL_ONE, eventListener)
Sinse version 0.1.2 you can use extension and inline functions of KDispatcher. All you need to do is implement IKDispatcher
interface. Also you can use single lambda functions like (Notification<T:Any>) -> Unit
as event handlers
class MainActivity : AppCompatActivity(), IKDispatcher {
private val eventListenerOne = this::eventOneHandler
//...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
scopeOperation()
}
private fun scopeOperation() {
// subscribe event to this handlers
subscribe(EVENT_CALL_ONE, eventListenerOne, 3)
subscribe(EVENT_CALL_ONE, ::eventListenerTwo, 1)
subscribe(EVENT_CALL_ONE, MyClass::eventListenerFour, 2)
// call event
call(EVENT_CALL_ONE, "FIRST CALL FROM KDISPATCHER")
/**
* But you can simple use inner lambda function to handler notification.
* So as u hasn't a reference to ISubscriber handler function, when you call
* `usubscribe(String)` you will delete all references ISubscriber-listener
*/
val eventName = "LAMBDA_EVENT"
subscribe<String>(eventName) { notification ->
println("LAMBDA_EVENT HAS FIRED with event name ${notification.eventName} and data ${notification.data}")
unsubscribe(notification.eventName)
}
call(eventName, "FIRST CALL CUSTOM LABDA EVENT")
/**
* Since version 0.1.7 you can subscribe by scope of events by a single callback
*/
subscribeList<Any>(listOf("notif_one", "notif_two")) {
when(it.eventName) {
"notif_one" -> Toast.makeText(this, "This is notif_one", Toast.LENGTH_SHORT).show()
"notif_two" -> Toast.makeText(this, "This is notif_two", Toast.LENGTH_SHORT).show()
}
}
call("notif_one")
call("notif_two")
}
fun eventOneHandler(notification:Notification<Any>) {
println("eventOneHandler MY TEST IS COMING event = ${notification.eventName} AND data = ${notification.data}")
}
}
Gradle:
implementation 'com.rasalexman.kdispatcher:kdispatcher:x.y.z'
Maven:
<dependency>
<groupId>com.rasalexman.kdispatcher</groupId>
<artifactId>kdispatcher</artifactId>
<version>x.y.z</version>
<type>pom</type>
</dependency>
- ThreadSafe
- Simple
- Usefull
License
MIT License
Copyright (c) 2019 Alexandr Minkin ([email protected])
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.
*Note that all licence references and agreements mentioned in the KDispatcher README section above
are relevant to that project's source code only.