{"id":13537338,"url":"https://github.com/abhimuktheeswarar/Flywheel","last_synced_at":"2025-04-02T04:30:38.016Z","repository":{"id":48341444,"uuid":"380572734","full_name":"abhimuktheeswarar/Flywheel","owner":"abhimuktheeswarar","description":"A simple and predictable state management library inspired by Redux for Kotlin Multiplatform using the concepts of actors.","archived":false,"fork":false,"pushed_at":"2023-03-02T09:31:25.000Z","size":49823,"stargazers_count":43,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T01:03:53.614Z","etag":null,"topics":["android","concurrency","coroutines","elm-architecture","flux","flux-architecture","kotlin","kotlin-multiplatform","mvi","mvi-android","mvi-architecture","redux","redux-actions","redux-store","state-management","unidirectional-data-flow"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abhimuktheeswarar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-06-26T18:35:40.000Z","updated_at":"2024-09-04T21:11:26.000Z","dependencies_parsed_at":"2023-09-27T03:38:18.995Z","dependency_job_id":null,"html_url":"https://github.com/abhimuktheeswarar/Flywheel","commit_stats":{"total_commits":92,"total_committers":2,"mean_commits":46.0,"dds":"0.19565217391304346","last_synced_commit":"7691042c1715ccff725349de7c3c489d293b3e3c"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhimuktheeswarar%2FFlywheel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhimuktheeswarar%2FFlywheel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhimuktheeswarar%2FFlywheel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhimuktheeswarar%2FFlywheel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhimuktheeswarar","download_url":"https://codeload.github.com/abhimuktheeswarar/Flywheel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246756826,"owners_count":20828774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","concurrency","coroutines","elm-architecture","flux","flux-architecture","kotlin","kotlin-multiplatform","mvi","mvi-android","mvi-architecture","redux","redux-actions","redux-store","state-management","unidirectional-data-flow"],"created_at":"2024-08-01T09:00:57.808Z","updated_at":"2025-04-02T04:30:33.006Z","avatar_url":"https://github.com/abhimuktheeswarar.png","language":"Objective-C","funding_links":[],"categories":["Libraries"],"sub_categories":["Architecture"],"readme":"# **Flywheel**\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.msabhi/flywheel?style=flat)](https://search.maven.org/search?q=com.msabhi.flywheel)\n[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)\n[![Kotlin](https://img.shields.io/badge/kotlin-1.7.20-blue.svg?logo=kotlin)](http://kotlinlang.org)\n![badge-android](https://img.shields.io/badge/platform-android-3DDC84.svg?style=flat)\n![badge-jvm](https://img.shields.io/badge/platform-jvm-red.svg?style=flat)\n![badge-apple](https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey?style=flat)\n![badge-js](https://img.shields.io/badge/platform-js-yellow.svg?style=flat)\n![badge-linux](https://img.shields.io/badge/platform-linux-important.svg?style=flat)\n![badge-windows](https://img.shields.io/badge/platform-windows-informational.svg?style=flat)\n![badge-native](https://img.shields.io/badge/platform-native-lightgrey.svg?style=flat)\n\n\nA simple and predictable state management library inspired by [Flux](https://facebook.github.io/flux/docs/in-depth-overview) + [Elm](https://guide.elm-lang.org/architecture/) + [Redux](https://github.com/reactjs/redux). Flywheel is built on top of [Corotuines](https://kotlinlang.org/docs/coroutines-overview.html) using the concepts of [structured concurrency](https://kotlinlang.org/docs/coroutines-basics.html#structured-concurrency). At the core, lies the [State Machine](https://en.wikipedia.org/wiki/Finite-state_machine) which is based on [actor model](https://en.wikipedia.org/wiki/Actor_model).\n\n\n## **Why Flywheel?**\n\nThe goal was to make the state management concept of Redux simple, understandable \u0026 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.\n\n\n## **Getting started**\n\n#### In Kotlin Multiplatfrom project:\n\n```Kotlin\nkotlin {\n  sourceSets {\n      val commonMain by getting {\n          dependencies {\n              implementation(\"com.msabhi:flywheel:1.1.5-RC\")\n          }\n      }\n  }\n}\n```\n\n#### In Android / Gradle project:\n\n```Kotlin\ndependencies {\n\n    implementation(\"com.msabhi:flywheel-android:1.1.5-RC\")\n}\n```\n\n\n#### In Apple platforms\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fabhimuktheeswarar%2FFlywheel%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/abhimuktheeswarar/Flywheel)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fabhimuktheeswarar%2FFlywheel%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/abhimuktheeswarar/Flywheel)\n\nYou can use the [Swift Package Manager](https://swift.org/package-manager) to install `Flywheel` by adding the proper description to your `Package.swift` file:\n\n```swift\n// swift-tools-version:5.3\nimport PackageDescription\n\nlet package = Package(\n    name: \"YOUR_PROJECT_NAME\",\n    dependencies: [\n        .package(url: \"https://github.com/abhimuktheeswarar/Flywheel.git\", from: \"1.1.5-RC\"),\n    ]\n)\n```\nThen run `swift build` whenever you get prepared.\n\n## **Usage**\n\nThis is how a simple counter example looks like.\n\n1. Define a state.\n\n    ```Kotlin\n    data class CounterState(val counter: Int = 0) : State\n    ```\n\n2. Define actions that can change the state.\n\n    ```Kotlin\n    sealed interface CounterAction : Action {\n\n        object IncrementAction : CounterAction\n\n        object DecrementAction : CounterAction\n    }\n    ```\n\n3. Define a reducer that updates the state based on the action \u0026 current state.\n\n    ```Kotlin\n    val reduce = reducerForAction\u003cCounterAction, CounterState\u003e { action, state -\u003e\n        with(state) {\n            when (action) {\n                is CounterAction.IncrementAction -\u003e copy(counter = counter + 1)\n                is CounterAction.DecrementAction -\u003e copy(counter = counter - 1)\n            }\n        }\n    }\n    ```\n\n4. Create a StateReserve.\n\n    ```Kotlin\n    val stateReserve = StateReserve(\n        initialState = InitialState.set(CounterState()),\n        reduce = reduce)\n    ```\n\n5. Listen for state changes\n\n    ```Kotlin\n    stateReserve.states.collect { state -\u003e println(state.counter) }\n    ```\n\n6. Send actions to StateReserve to update the state.\n\n    ```Kotlin\n    stateReserve.dispatch(IncrementAction)\n    ```\n\n\n### To learn more about Flywheel, head on over to our [wiki](https://github.com/abhimuktheeswarar/Flywheel/wiki).\n\n\n## **License**\n\n```License\nCopyright (C) 2021 Abhi Muktheeswarar\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhimuktheeswarar%2FFlywheel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhimuktheeswarar%2FFlywheel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhimuktheeswarar%2FFlywheel/lists"}