### Install Android Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/examples/taskflow/README.md Install the debug version of the Android application. This requires an Android SDK to be present. ```bash # Android (requires an Android SDK; the androidApp module is only included when one is present) ./gradlew :examples:taskflow:androidApp:installDebug ``` -------------------------------- ### Install TaskFlow Android Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/introduction/Examples.md Clone the repository and install the TaskFlow example application on an Android device. ```sh git clone https://github.com/reduxkotlin/redux-kotlin.git ./gradlew :examples:taskflow:androidApp:installDebug ``` -------------------------------- ### Run Todos Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/introduction/Examples.md Clone the repository and install the Todos example application on Android. ```sh git clone https://github.com/reduxkotlin/redux-kotlin.git ./gradlew :examples:todos:android:installDebug ``` -------------------------------- ### Run Counter Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/introduction/Examples.md Clone the repository and install the Counter example application on Android. ```sh git clone https://github.com/reduxkotlin/redux-kotlin.git ./gradlew :examples:counter:android:installDebug ``` -------------------------------- ### Update CLI Installation Instructions Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-06-19-unified-rk-cli-phase2.md Example of how to present installation instructions for the 'rk' CLI, prioritizing package managers (Homebrew, Scoop) and providing a fallback for source builds. It also notes that package manager installations include a bundled JRE. ```shell # macOS / Linux brew install reduxkotlin/tap/rk # Windows scoop bucket add reduxkotlin https://github.com/reduxkotlin/scoop-bucket scoop install rk # From source (any OS, needs JDK 17+) ./gradlew :redux-kotlin-cli:installDist # → redux-kotlin-cli/build/install/rk/bin/rk ``` -------------------------------- ### Redux-Kotlin Quick Start Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/redux-kotlin/README.md A basic example demonstrating how to create a Redux store with a simple reducer, dispatch an action, and subscribe to state changes. Note that `createStore` is not thread-safe by default. ```kotlin import org.reduxkotlin.createStore data class AppState(val count: Int = 0) sealed interface Action data object Increment : Action val reducer = { state: AppState, action: Any -> when (action) { is Increment -> state.copy(count = state.count + 1) else -> state } } val store = createStore(reducer, AppState()) val unsubscribe = store.subscribe { println(store.state.count) } store.dispatch(Increment) // prints 1 unsubscribe() ``` -------------------------------- ### Run TaskFlow Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/introduction/Examples.md Clone the repository and run the TaskFlow example application on desktop. ```sh git clone https://github.com/reduxkotlin/redux-kotlin.git ./gradlew :examples:taskflow:composeApp:run # desktop ``` -------------------------------- ### Install Website Dependencies Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/README.md Run this command to install all necessary dependencies for the website. ```sh # Install dependencies $ yarn install ``` -------------------------------- ### Start Development Server Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/README.md Execute this command to start the local development server for the website. ```sh # Start the site $ yarn start ``` -------------------------------- ### Configure and Start DevTools Bridge Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/advanced/DevTools.md Initialize the Redux-Kotlin store with DevTools support and start the bridge to connect to the standalone monitor. This example shows basic configuration for a single store. ```kotlin import org.reduxkotlin.devtools.bridge.BridgeConfig import org.reduxkotlin.devtools.bridge.BridgeOutput val cfg = DevToolsConfig(name = "appStore") val store = createStore(reducer, AppState(), devTools(cfg)) DevToolsHub.session(cfg.instanceId ?: cfg.name)?.let { session -> BridgeOutput(BridgeConfig(clientId = "myapp", clientLabel = "MyApp · desktop")).start(session) } ``` -------------------------------- ### Redux Store Configuration Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/specs/2026-05-28-routing-codegen-phase2-design.md Example of how to create a Redux store and install the generated `ReduxModule` in the application. ```kotlin val store = createModelStore { install(GeneratedReduxModule) } ``` -------------------------------- ### Build and Run Web (wasmJs) Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/examples/taskflow/README.md Build the production bundle for the wasmJs target and then run a development server for the composeApp example. ```bash # Web (wasmJs) — production bundle, then a dev server ./gradlew :examples:taskflow:composeApp:wasmJsBrowserDistribution ./gradlew :examples:taskflow:composeApp:wasmJsBrowserRun ``` -------------------------------- ### Run Desktop (JVM) Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/examples/taskflow/README.md Execute the Gradle task to run the composeApp example on a JVM desktop environment. ```bash # Desktop (JVM) ./gradlew :examples:taskflow:composeApp:run ``` -------------------------------- ### Install Redux-Kotlin CLI with Homebrew/Scoop Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/advanced/DevToolsCLITutorial.md Install the Redux-Kotlin CLI using package managers for a bundled JRE. This is the recommended installation method. ```bash # macOS / Linux brew install reduxkotlin/tap/rk ``` ```bash # Windows scoop bucket add reduxkotlin https://github.com/reduxkotlin/scoop-bucket scoop install rk ``` -------------------------------- ### Install ReduxModule to Contribute Models and Handlers Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-05-28-redux-kotlin-routing-phase1.md Demonstrates how to install a `ReduxModule` into a `createModelStore` builder. The installed module contributes its models and associated handlers to the store. ```kotlin package org.reduxkotlin.routing import kotlin.test.Test import kotlin.test.assertEquals private data class Audit(val log: List = emptyList()) class ModuleInstallTest { private val userModule = ReduxModule { model(UserModel()) { on { s, a -> s.copy(user = a.user) } } } @Test fun installed_module_contributes_models_and_handlers() { val s = createModelStore { install(userModule) } s.dispatch(LoggedIn("ann")) assertEquals("ann", s.state.get().user) } @Test fun handler_order_follows_install_order() { // Two handlers for the same action append to the audit log in // registration order; install order is the composition point. val first = ReduxModule { model(Audit()) { on { a, _ -> a.copy(log = a.log + "first") } } } val second = ReduxModule { onAction { reads, _ -> val a = reads.get() writeSet { set(a.copy(log = a.log + "second")) } } } val s = createModelStore { install(first) install(second) } s.dispatch(Checkout) assertEquals(listOf("first", "second"), s.state.get().log) } } ``` -------------------------------- ### Git Commit Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-06-03-single-source-assembler.md Example git command to add and commit the newly created documentation fragments. ```bash git add docs/agent/_fragments && git commit -m "docs(agent): add single-source fragments (rules, module map)" ``` -------------------------------- ### Install and Test RK CLI via Homebrew Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-06-19-unified-rk-cli-phase2.md Commands to tap the Redux Kotlin Homebrew repository, install the 'rk' CLI, and verify its installation by checking the version and help output. This assumes the Homebrew formula is correctly set up. ```bash brew tap reduxkotlin/tap brew install reduxkotlin/tap/rk rk --version # expect: rk version rk devtools --help ``` -------------------------------- ### Install rk CLI with Scoop Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/devtools.md Installs the `rk` CLI tool on Windows using Scoop. This method includes a bundled JRE, so no separate Java installation is required. ```bash # Windows scoop bucket add reduxkotlin https://github.com/reduxkotlin/scoop-bucket scoop install rk ``` -------------------------------- ### Store Creation with Handler Installation Order Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/specs/2026-05-28-reducer-middleware-routing-design.md Demonstrates how to create a Redux-Kotlin store and define the order of module installations, which dictates the sequence of handlers during dispatch. ```kotlin val store = createModelStore(initialModels) { install(UserModule) // ← order here defines cross-module handler sequence install(CartModule) install(CheckoutModule) } ``` -------------------------------- ### Install RK CLI via Scoop Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/specs/2026-06-19-unified-rk-cli-design.md Use this command to install the Redux Kotlin CLI on Windows systems that use Scoop. ```bash scoop install rk ``` -------------------------------- ### Migrate to Concurrent Store Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/redux-kotlin-threadsafe/README.md Example demonstrating the migration from createThreadSafeStore to createConcurrentStore. ```kotlin val store = createThreadSafeStore(reducer, state, enhancer = enhancer) // after val store = createConcurrentStore(reducer, state, enhancer = enhancer) ``` -------------------------------- ### rk-devtools example agent call Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/specs/2026-06-04-redux-kotlin-devtools-cli-design.md An example of a typical agent command using `rk-devtools diff` with specific filters for store, action type, and the number of last actions to retrieve. ```bash rk-devtools diff --store account:ann --type '*Card*' --last 10 ``` -------------------------------- ### Start Redux DevTools Server and UI Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/specs/2026-06-01-redux-devtools-integration-design.md Run the Redux DevTools CLI to start the server and open the monitor UI. This typically runs on port 8000. ```bash npx @redux-devtools/cli --open // server + UI :8000 ``` -------------------------------- ### Desktop Main Entry Point Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-06-02-redux-kotlin-devtools-standalone-app.md Sets up the main window for the desktop application using Compose UI. It initializes the MonitorIngest and MonitorServer, starts the server, and displays the MonitorApp. ```kotlin package org.reduxkotlin.devtools.monitor import androidx.compose.ui.window.Window import androidx.compose.ui.window.application public fun main() { val ingest = MonitorIngest() val server = MonitorServer(ingest) // binds 127.0.0.1:9090 server.start() application { Window(onCloseRequest = { server.stop(); exitApplication() }, title = "Redux DevTools Monitor") { val state = rememberMonitorState(ingest) MonitorApp(ingest, state) } } } ``` -------------------------------- ### Link iOS Framework Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/examples/taskflow/README.md Link the shared framework for the iOS simulator (arm64 architecture). This requires a Mac and Xcode iOS SDK. Refer to iosApp/README.md for host setup. ```bash # iOS — link the shared framework (Mac + Xcode iOS SDK); see iosApp/README.md for the host ./gradlew :examples:taskflow:composeApp:linkDebugFrameworkIosSimulatorArm64 ``` -------------------------------- ### Redux-Kotlin Registry Module README Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-05-27-store-registry.md This README introduces the redux-kotlin-registry module, explaining its purpose as a thread-safe registry for Redux stores keyed by unique identifiers. It provides guidance on when to use the registry and a quick start example. ```markdown # redux-kotlin-registry A thread-safe registry for multiple [redux-kotlin](../redux-kotlin) stores, keyed by a unique identifier of your choosing. ## When to use Whenever your app has scoped state that must not bleed between instances: - Per-thread-view store in a messaging app. - Per-call store in a calling app. - Per-screen store driven by a route identifier. ## Quick start (Tier 1 — same state type, many ids) ```kotlin import org.reduxkotlin.createStore import org.reduxkotlin.registry.RegistryEvent import org.reduxkotlin.registry.StoreRegistry typealias ThreadId = String val threadStores = StoreRegistry() fun openThread(id: ThreadId) = threadStores.getOrCreate(id) { createStore(threadReducer, ThreadState()) } fun closeThread(id: ThreadId) { threadStores.remove(id) } fun onLogout() { threadStores.clear() } val off = threadStores.addListener { event -> when (event) { is RegistryEvent.Added -> telemetry.log("thread_store_opened", event.id) is RegistryEvent.Removed -> telemetry.log("thread_store_closed", event.id) } } // later: off() ``` ``` -------------------------------- ### Install rk CLI via Homebrew/Scoop Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/agent/AGENTS-external.md Install the 'rk' CLI tool using Homebrew on macOS/Linux or Scoop on Windows. This installation includes a bundled JRE, so no separate Java installation is required. ```bash # macOS / Linux brew install reduxkotlin/tap/rk # Windows scoop bucket add reduxkotlin https://github.com/reduxkotlin/scoop-bucket scoop install rk ``` -------------------------------- ### Configure build.gradle.kts for Routing Codegen Sample Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-05-28-routing-codegen-phase2.md Sets up the build script for the sample integration module, including KSP plugin, dependencies, and KSP arguments for code generation. Ensure 'convention.library-mpp-loved' and 'com.google.devtools.ksp' plugins are applied. ```kotlin plugins { id("convention.library-mpp-loved") id("com.google.devtools.ksp") } dependencies { add("kspCommonMainMetadata", project(":redux-kotlin-routing-codegen")) } ksp { arg("routing.moduleName", "SampleModule") arg("routing.generatedPackage", "org.reduxkotlin.routing.sample.generated") } kotlin { sourceSets { commonMain { kotlin.srcDir("build/generated/ksp/metadata/commonMain/kotlin") dependencies { api(project(":redux-kotlin-routing")) } } } } tasks.withType>().configureEach { if (name != "kspCommonMainKotlinMetadata") dependsOn("kspCommonMainKotlinMetadata") } ``` -------------------------------- ### Installing Generated ReduxModule Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/redux-kotlin-routing-codegen/README.md Integrate the generated ReduxModule into your Redux store. The generated object, named according to the 'routing.moduleName' argument, is installed using the `install` function. ```kotlin val store = createModelStore { install(MyFeature) } ``` -------------------------------- ### Configure and Start DevTools Bridge Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/devtools.md Configure the DevTools settings with a name and create a store. Then, register a BridgeOutput to stream store sessions to the standalone monitor. ```kotlin val cfg = DevToolsConfig(name = "appStore") val store = createStore(reducer, AppState(), devTools(cfg)) DevToolsHub.session(cfg.instanceId ?: cfg.name)?.let { session -> BridgeOutput(BridgeConfig(clientId = "myapp", clientLabel = "MyApp · desktop")).start(session) } ``` -------------------------------- ### Dispatch Actions and Subscribe to State Changes Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/basics/Store.md Demonstrates how to log initial state, subscribe to state changes, dispatch various actions, and unsubscribe from updates. This example requires a logger and predefined actions/filters. ```kotlin fun main() { //log the initial state logger.info(store.state) // Every time the state changes, log it // Not that subscribe() returns a function for unregistering the listener val unsubscribe = store.subscribe { logger.info(store.state) } // Dispatch some actions store.dispatch(AddTodo("Learn about actions")) store.dispatch(AddTodo("Learn about reducers")) store.dispatch(AddTodo("Learn about store")) store.dispatch(ToggleTodo(0)) store.dispatch(ToggleTodo(1)) store.dispatch(SetVisibilityFilter(VisibilityFilters.SHOW_COMPLETED)) // Stop listening to state updates unsubscribe() } ``` -------------------------------- ### Create Model Store with Routing DSL Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-05-28-redux-kotlin-routing-phase1.md Demonstrates the builder pattern for creating a `Store` using `createModelStore`. It shows how to define initial model instances, register single-model handlers using `on`, multi-model handlers returning a write-set using `onAction`, broadcast handlers using `onBroadcast`, and compose modules using `install`. ```kotlin val store: Store = createModelStore( devChecks = false, // opt-in immutability assertion onWrite = null, // opt-in !==-gated write observer ) { model(UserModel()) { // structural init: instance supplied here on { s, a -> s.copy(user = a.user) } // single-model, pure (M,A)->M on { s, _ -> s.copy(user = null) } } model(CartModel()) { on { s, a -> s.copy(items = s.items + a.item) } } onAction { reads, a -> // multi-model, returns a write-set val cart = reads.get() writeSet { set(cart.copy(closed = true)) set(reads.get().copy(lastOrder = cart.id)) } } onBroadcast { model, _ -> // runs for every installed model if (model is Clearable) model.cleared() else model } install(SomeFeatureModule) // modular composition; order fixed here } ``` -------------------------------- ### Install rk CLI with Homebrew Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/devtools.md Installs the `rk` CLI tool on macOS or Linux using Homebrew. This method includes a bundled JRE, so no separate Java installation is required. ```bash # macOS / Linux brew install reduxkotlin/tap/rk ``` -------------------------------- ### Get or Create Store from Registry Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/examples/taskflow/README.md Builds the per-account store and its handle, mirrors the bare Store into the registry, and serves it lock-free on later lookups. The bundle also ships a one-call extension. ```kotlin getOrCreate(key) { … } (registry) ``` -------------------------------- ### ServeCommand Implementation Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-06-04-redux-kotlin-devtools-cli.md Hosts the bridge receiver, writes per-store captures, and optionally launches the GUI monitor. It can be configured with port, host, token, and output directory. ```kotlin package org.reduxkotlin.devtools.cli.command import androidx.compose.ui.window.Window import androidx.compose.ui.window.application import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.default import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.types.int import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.runBlocking import org.reduxkotlin.devtools.cli.server.startFlushing import org.reduxkotlin.devtools.monitor.MonitorIngest import org.reduxkotlin.devtools.monitor.MonitorServer import org.reduxkotlin.devtools.monitor.rememberMonitorState import org.reduxkotlin.devtools.monitor.ui.MonitorApp import java.io.File /** `serve` — host the bridge receiver, write per-store captures, optionally launch the GUI. */ internal class ServeCommand : CliktCommand(name = "serve") { private val port by option("--port").int().default(9090) private val host by option("--host").default("127.0.0.1") private val token by option("--token") private val out by option("--out").default(".rk-devtools") private val ui by option("--ui", help = "also launch the GUI monitor").flag() override fun run() { val dir = File(out).apply { mkdirs() } val ingest = MonitorIngest() val server = MonitorServer(ingest, port = port, host = host, token = token) val bound = server.start() val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default) startFlushing(scope, ingest, dir) echo("serving bridge on $host:$bound → captures in ${dir.path}") if (ui) { application { Window(onCloseRequest = { server.stop(); exitApplication() }, title = "Redux DevTools Monitor") { MonitorApp(ingest, rememberMonitorState(ingest)) } } } else { runBlocking { kotlinx.coroutines.awaitCancellation() } } } } ``` -------------------------------- ### Install RK CLI Distribution Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/specs/2026-06-19-unified-rk-cli-design.md Command to build and install the distribution for the `redux-kotlin-cli` module. ```bash ./gradlew :redux-kotlin-cli:installDist ``` -------------------------------- ### Create a Model Store with Routing Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/redux-kotlin-routing/README.md Demonstrates the setup of a model store using redux-kotlin-routing, including defining models, their reducers, and handling specific actions. Use this to initialize your application's state and logic. ```kotlin val store = createModelStore { model(UserModel()) { on { s, a -> s.copy(user = a.user) } on { s, _ -> s.copy(user = null) } } model(CartModel()) { on { s, a -> s.copy(items = s.items + a.item) } } onAction { reads, _ -> val cart = reads.get() writeSet { set(cart.copy(closed = true)) } } onBroadcast { model, _ -> /* reset each model */ model } install(SomeFeatureModule) } ``` -------------------------------- ### Reorder Subscription Install and Re-sample in FieldState Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-06-10-concurrent-store-hardening.md This snippet shows the reordering of install and re-sample operations within a DisposableEffect in FieldState.kt. It ensures that the subscription is installed before the state is re-sampled, addressing potential race conditions. ```kotlin DisposableEffect(store, rememberedSelector) { val sub = store.subscribeTo(selector = rememberedSelector, triggerOnSubscribe = false) { _, _ -> tick.intValue++ } // B3 re-sample AFTER install: a change before install is caught here (compared // against the first-composition `initial`); a change after install is caught by // the subscription (guaranteed-fresh post-C1). Overlap = one redundant tick bump. if (rememberedSelector(store.state) != initial) tick.intValue++ onDispose { sub() } } ``` -------------------------------- ### Accessing ModelState Models via get(KClass) Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-05-29-taskflow-bundle-sample.md Use the public `get(KClass)` method to access models from `ModelState` as `ModelState.models` is `@PublishedApi internal`. The `get` method always succeeds and does not return null. ```kotlin inline fun ModelState.getModel(): M = get(M::class) ``` -------------------------------- ### Dispatching Actions Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-05-29-taskflow-bundle-sample.md Illustrates how to dispatch an action to the store. ```kotlin store.dispatch(action) ``` -------------------------------- ### Serve DevTools UI Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/advanced/DevToolsCLITutorial.md Start a local server to access the Redux-Kotlin DevTools GUI by running the `serve --ui` command. This provides a visual interface for inspecting state and actions. ```bash rk devtools serve --ui ``` -------------------------------- ### Install Distributable for DevTools CLI Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-06-04-redux-kotlin-devtools-cli.md Builds and installs the distributable package for the Redux Kotlin DevTools CLI, making it ready for deployment. ```bash ./gradlew :redux-kotlin-devtools-cli:installDist ``` -------------------------------- ### Create Source Directories and .gitkeep Files Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-05-27-store-registry.md Set up the necessary directory structure for the new module, including common, commonTest, and jvmTest source sets, and add empty '.gitkeep' files to ensure directories are tracked by Git. ```bash mkdir -p redux-kotlin-registry/src/commonMain/kotlin/org/reduxkotlin/registry mkdir -p redux-kotlin-registry/src/commonTest/kotlin/org/reduxkotlin/registry mkdir -p redux-kotlin-registry/src/jvmTest/kotlin/org/reduxkotlin/registry/concurrency touch redux-kotlin-registry/src/commonMain/kotlin/org/reduxkotlin/registry/.gitkeep touch redux-kotlin-registry/src/commonTest/kotlin/org/reduxkotlin/registry/.gitkeep touch redux-kotlin-registry/src/jvmTest/kotlin/org/reduxkotlin/registry/concurrency/.gitkeep ``` -------------------------------- ### Run the CLI Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/agent/references/snapshot.md Wire your scene registry into a `main` function that calls `runCli` to execute snapshot tests from the command line. This example uses the `taskFlowSnapshots` registry. ```kotlin fun main(args: Array) = taskFlowSnapshots.runCli(args) ``` -------------------------------- ### Installing Redux Modules into RoutingBuilder Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/plans/2026-05-28-redux-kotlin-routing-phase1.md Extension function to apply a `ReduxModule`'s registrations to a `RoutingBuilder`. Modules are applied in the order they are installed. ```kotlin public fun RoutingBuilder.install(module: ReduxModule) { with(module) { contribute() } } ``` -------------------------------- ### Custom Logger Middleware Example Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/website/docs/api/applyMiddleware.md An example demonstrating how to create and use a custom logger middleware to log actions and state changes. ```APIDOC ## Custom Logger Middleware Example ### Description This example shows how to define a logger middleware that logs actions before they are dispatched and the state after the dispatch has occurred. It then demonstrates how to apply this middleware when creating a Redux store. ### Code ```kotlin fun loggerMiddleware2(store: Store) = { next: Dispatcher -> { action: Any -> Logger.d("will dispatch $action") // Call the next dispatch method in the middleware chain. val returnValue = next(action) Logger.d("state after dispatch: ${store.state}") // This will likely be the action itself, unless // a middleware further in chain changed it. result } } val store = createThreadSafeStore(todos, AppState.INITIAL_STATE, applyMiddleware(::logger)) store.dispatch(AddTodoAction(text = "Understand middleware")) // (These lines will be logged by the middleware:) // will dispatch: AddTodoAction(text = "Understand middleware") // state after dispatch: AppState(todos = [AddTodo(text = "Understand middleware")]) ``` ### Usage 1. Define your middleware function conforming to the `Middleware` typealias. 2. Pass your middleware function to `applyMiddleware()`. 3. Pass the result of `applyMiddleware()` as an enhancer to `createThreadSafeStore()`. ``` -------------------------------- ### Run Full Build Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/AGENTS.md Executes the complete build process, including compilation, testing, linting with Detekt, and API check. ```bash ./gradlew build ``` -------------------------------- ### Install RK CLI via Homebrew Source: https://github.com/reduxkotlin/redux-kotlin/blob/master/docs/superpowers/specs/2026-06-19-unified-rk-cli-design.md Use this command to install the Redux Kotlin CLI on macOS or Linux systems that use Homebrew. ```bash brew install reduxkotlin/tap/rk ```