{"id":13659026,"url":"https://github.com/getspherelabs/meteor-kmp","last_synced_at":"2025-04-12T04:41:55.008Z","repository":{"id":170205950,"uuid":"646328849","full_name":"getspherelabs/meteor-kmp","owner":"getspherelabs","description":"Meteor is a simple framework that helps you to create application using the MVI architecture.","archived":false,"fork":false,"pushed_at":"2023-10-06T01:27:37.000Z","size":6417,"stargazers_count":56,"open_issues_count":11,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T00:11:36.683Z","etag":null,"topics":["hacktoberfest","hacktoberfest2023","kmm","kotlin","meteor","multiplatform","mvi"],"latest_commit_sha":null,"homepage":"https://getspherelabs.github.io/meteor-kmp/","language":"Kotlin","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/getspherelabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-28T03:13:04.000Z","updated_at":"2024-12-28T06:14:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"c2e365ef-c7b0-42b8-8459-69dbfce54d48","html_url":"https://github.com/getspherelabs/meteor-kmp","commit_stats":null,"previous_names":["getspherelabs/meteor","getspherelabs/meteor-kmp"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getspherelabs%2Fmeteor-kmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getspherelabs%2Fmeteor-kmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getspherelabs%2Fmeteor-kmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getspherelabs%2Fmeteor-kmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getspherelabs","download_url":"https://codeload.github.com/getspherelabs/meteor-kmp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519327,"owners_count":21117756,"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":["hacktoberfest","hacktoberfest2023","kmm","kotlin","meteor","multiplatform","mvi"],"created_at":"2024-08-02T05:01:04.669Z","updated_at":"2025-04-12T04:41:54.983Z","avatar_url":"https://github.com/getspherelabs.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":["🏗 Architecture"],"readme":"\u003ch1 align=\"center\"\u003eMeteor KMP\u003c/h1\u003e\u003c/br\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/getspherelabs/meteor\"\u003e\u003cimg  alt=\"Meteor Banner\" src=\"https://github.com/getspherelabs/meteor/blob/main/docs/images/Banner%20-%20%20Meteor.png?raw=true\"/\u003e\u003c/a\u003e \u003cbr\u003e\n\u003c/p\u003e\n\nMeteor is a simple framework that helps you to create application using the MVI architecture. It provides a robust structure for organizing your code and separating concerns. Additionally, Meteor integrates with Kotlin Coroutine that helps you to write asynchronous and concurrent code.\n\n## Features\n\n- Meteor follows the Model-View-Intent (MVI) architecture pattern.\n- It provides a unidirectional data flow (UDF), allowing you to handle state changes and propagate them to the UI efficiently.\n- Supports Kotlin Coroutines: asynchronous and concurrent code in a more concise and structured way.\n- Meteor supports Kotlin Multiplatform, allowing you to share code across multiple platforms.\n- Easy to test (integration and unit  tests).\n- Additional features like common use cases, state flow, view model and logger.\n\n## Documentation 📖\n\n- [Getting Started](https://getspherelabs.github.io/meteor/guides/getting-started)\n- [Core Concepts](https://getspherelabs.github.io/meteor/guides/concepts)\n- [Common Components](https://getspherelabs.github.io/meteor/common/vm)\n  - [Common ViewModel](https://getspherelabs.github.io/meteor/common/vm)  \n  - [Common Flow](https://getspherelabs.github.io/meteor/common/flow)\n  - [Common UseCase](https://getspherelabs.github.io/meteor/common/usecase)\n- [Testing](https://getspherelabs.github.io/meteor/test/tests)\n\n\n## Setup\n\nAdd the dependency below into your module's `build.gradle.kts` file:\n\n```kt\n\n// It includes viewmodel, stateflow and core components.\nimplementation(\"io.github.behzodhalil:meteor-mvi:\u003clatest-version\u003e\")\n// If only need common use case\nimplementation(\"io.github.behzodhalil:meteor-usecase:\u003clatest-version\u003e\")\n// For testing\ntestImplementation(\"io.github.behzodhalil:meteor-test:\u003clatest-version\u003e\")\n```\n### Define the contract\n\n\n```kt\ndata class CountState(\n    val count: Int = 0\n)\n\nsealed interface CountWish {\n    object Increase : CountWish\n    object Decrease : CountWish\n    object Reset : CountWish\n    object ZeroValue : CountWish\n}\n\nsealed interface CountEffect {\n    data class Failure(val message: String) : CountEffect\n}\n```\n\n`State` represents the current state of your application. `Effects` are a way to handle side effects in Meteor. Side effects can include operations such as making network requests, updating a database, displaying UI messages, or triggering external actions.  A `Wish` in Meteor represents an action or an intention to change the state of the application.\n\n### Create the ViewModel\n\nDefine a ViewModel class, such as `MainViewModel`, that extends `CommonViewModel` with the appropriate state, wish, and effect types:\n\n```kt\nclass MainViewModel : CommonViewModel\u003cCountState, CountWish, CountEffect\u003e() {\n      // ....\n}\n```\n\nInside your ViewModel, override the store property by creating a `Meteor` store using the `createMeteor` function and providing the necessary configurations:\n\n```kt\n    override val store: Store\u003cCountState, CountWish, CountEffect\u003e = createMeteor(\n        configs = MeteorConfigs.build {\n            initialState = CountState.Empty\n            storeName = \"MainViewModel\"\n            reducer = CountReducer\n            middleware = CountMiddleware\n        }\n    )\n```\n\nDefine properties for effect and state in your ViewModel, which will expose the effect and state as `CommonFlow` and `CommonStateFlow`, respectively:\n\n```kt\nval effect: NonNullCommonFlow\u003cCountEffect\u003e = store.effect.asCommonFlow()\nval state: NonNullCommonStateFlow\u003cCountState\u003e = store.state.asCommonStateFlow()\n\n```\n\n### Define Reducer and Middleware\n\nCreate an object / class , such as `CountReducer`, that implements the `Reducer` interface with the appropriate state, wish, and effect types:\n\n```kt\n    object CountReducer : Reducer\u003cCountState, CountWish, CountEffect\u003e {\n        override fun reduce(state: CountState, wish: CountWish): Change\u003cCountState, CountEffect\u003e {\n            return when (wish) {\n                CountWish.Decrease -\u003e {\n                    expect { state.copy(count = state.count - 1) }\n                }\n                CountWish.Increase -\u003e {\n                    expect { state.copy(count = state.count + 1) }\n                }\n                CountWish.Reset -\u003e {\n                    expect { state.copy(count = 0) }\n                }\n                CountWish.ZeroValue -\u003e {\n                    effect {\n                        CountEffect.Failure(\"The value is zero\")\n                    }\n                }\n            }\n        }\n\n    }\n\n```\n\n### Using in Fragment / Compose\n\n```kt\n\nviewModel.state.onEach { state -\u003e\n    // Handle the state\n}.launchIn(lifecycleScope)\n\nviewModel.effect.onEach { effect -\u003e\n    // Handle the effect, such as displaying a toast message or triggering an action\n}.launchIn(lifecycleScope)\n\n\n```\n## Inspired by\n\n* [Orbit MVI](https://github.com/orbit-mvi/orbit-mvi)\n* [MVIKotlin](https://github.com/arkivanov/MVIKotlin)\n\n## Credits\n* [kmp-viewmodel](https://github.com/hoc081098/kmp-viewmodel/tree/master/viewmodel)\n  \n## License\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE.md)\n\nThis project is licensed under the Apache License, Version 2.0 - see the\n[license](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetspherelabs%2Fmeteor-kmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetspherelabs%2Fmeteor-kmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetspherelabs%2Fmeteor-kmp/lists"}