Swiftpack.co - abhimuktheeswarar/Flywheel as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A simple and predictable state management library inspired by Redux for Kotlin Multiplatform using the concepts of actors.
.package(url: "https://github.com/abhimuktheeswarar/Flywheel.git", from: "v1.1.3-RC")


Maven Central GitHub License Kotlin badge-android badge-jvm badge-apple badge-js badge-linux badge-windows badge-native

A simple and predictable state management library inspired by Flux + Elm + Redux. Flywheel is built on top of Corotuines using the concepts of structured concurrency. At the core, lies the State Machine which is based on actor model.

Why Flywheel?

The goal was to make the state management concept of Redux simple, understandable & easy to use in Kotlin based projects. To achieve that, we adapted only the core concepts from Redux and slightly modified them. We excluded Android, Apple or any platform-specific dependencies. It is just pure Kotlin. By doing so, you are free to choose your architecture that best suits your codebase, no need to make any big refactor to fit in Flywheel. Don't be fooled by its simplicity, Flywheel got you covered for all practical use-cases. Even if we missed anything, it can be easily extended to support your use cases.

Getting started

In Kotlin Multiplatfrom project:

kotlin {
  sourceSets {
      val commonMain by getting {
          dependencies {

In Android / Gradle project:

dependencies {


In Apple platforms

You can use CocoaPods to install Flywheel by adding it to your Podfile:


target 'MyApp' do

    pod 'Flywheel', '~> 1.1.3-RC'


You can use the Swift Package Manager to install Flywheel by adding the proper description to your Package.swift file:

// swift-tools-version:5.3
import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .package(url: "https://github.com/abhimuktheeswarar/Flywheel.git", from: "1.1.3-RC"),

Then run swift build whenever you get prepared.


This is how a simple counter example looks like.

  1. Define a state.

    data class CounterState(val counter: Int = 0) : State
  2. Define actions that can change the state.

    sealed interface CounterAction : Action {
        object IncrementAction : CounterAction
        object DecrementAction : CounterAction
  3. Define a reducer that updates the state based on the action & current state.

    val reduce = reducerForAction<CounterAction, CounterState> { action, state ->
        with(state) {
            when (action) {
                is CounterAction.IncrementAction -> copy(counter = counter + 1)
                is CounterAction.DecrementAction -> copy(counter = counter - 1)
  4. Create a StateReserve.

    val stateReserve = StateReserve(
        initialState = InitialState.set(CounterState()),
        reduce = reduce)
  5. Listen for state changes

    stateReserve.states.collect { state -> println(state.counter) }
  6. Send actions to StateReserve to update the state.


To learn more about Flywheel, head on over to our wiki.


Copyright (C) 2021 Abhi Muktheeswarar

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.


Stars: 12
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Fixes: Gradle build
10 weeks ago

Fix Gradle build for older Gradle versions.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics