reactive
5.1.2indexedMultiplatform library for building reactive applications with state management, data observation, error handling, and coroutines integration, inspired by Solid.js, featuring reactive data "lensing."
Multiplatform library for building reactive applications with state management, data observation, error handling, and coroutines integration, inspired by Solid.js, featuring reactive data "lensing."
Surfaced from shared tags and platforms — no rankings paid for.
Kotlin Multiplatform reactivity tools.
Reactive is a multiplatform Kotlin library for building reactive applications. It is inspired by concepts from Solid.js, and provides a set of core abstractions and utilities for managing state, observing changes, and composing reactive data flow.
Some of the features of Reactive include:
The core of Reactive is the Reactive<T> interface, which represents a reactive value that can be observed for changes
in state. The state of a Reactive not only communicates data, but also loading and error states. Reactive data can
be bound to a ReactiveContext, which handles all the observation, loading checks, and resource management for you.
As of now there isn't any official documentation for Reactive, but a good introduction to Reactive in action can be found here.
Simple example of reactive data:
val counter = Signal(0) // Signal is the most basic Reactive value. It's a container that notifies listeners when changed.
AppScope.reactive {
// ReactiveContexts are bound to kotlin CoroutineScopes
// AppScope is a provided top-level scope that lives as long as the app is running.
println("Count is now: ${counter()}") // Reactive data is bound to the scope using the `invoke()` operator.
}
fun {
counter.value =
counter.value =
}
Support for loading states:
val wait = LateInitSignal<String>() // LateInitSignal is like Signal, but starts in a loading state until set
AppScope.reactive {
println(wait()) // context will stay loading until wait has a ready value
}
fun go() {
wait.value = "Okay, stop loading now." // prints "Okay, stop loading now."
}
Interoperability with kotlinx-coroutines:
val data: Flow<Int> = flow {
repeat(10) {
delay(1000)
emit(it)
}
}
AppScope.reactive {
println(data()) // prints "1", "2", ..., "9" delaying one second between each
}