{"id":16525937,"url":"https://github.com/haroldadmin/vector","last_synced_at":"2025-03-16T19:31:14.233Z","repository":{"id":53471007,"uuid":"190186711","full_name":"haroldadmin/Vector","owner":"haroldadmin","description":"Kotlin Coroutines based MVI architecture library for Android ","archived":false,"fork":false,"pushed_at":"2021-03-29T20:37:01.000Z","size":1538,"stargazers_count":193,"open_issues_count":13,"forks_count":8,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-18T20:36:05.807Z","etag":null,"topics":["android","android-library","android-mvi","kotlin","kotlin-coroutines","model-view-intent","mvi"],"latest_commit_sha":null,"homepage":"https://haroldadmin.github.io/Vector/","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/haroldadmin.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}},"created_at":"2019-06-04T11:18:39.000Z","updated_at":"2024-01-12T06:29:29.000Z","dependencies_parsed_at":"2022-09-10T01:50:10.878Z","dependency_job_id":null,"html_url":"https://github.com/haroldadmin/Vector","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2FVector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2FVector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2FVector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2FVector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haroldadmin","download_url":"https://codeload.github.com/haroldadmin/Vector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221667213,"owners_count":16860570,"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","android-library","android-mvi","kotlin","kotlin-coroutines","model-view-intent","mvi"],"created_at":"2024-10-11T17:08:03.869Z","updated_at":"2024-10-27T11:09:14.955Z","avatar_url":"https://github.com/haroldadmin.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vector\n\n![logo](docs/images/logo-full-coloured.svg)\n\n![Build and Test](https://github.com/haroldadmin/Vector/workflows/Build%20and%20Test/badge.svg)\n\nVector is an Android library to help implement the MVI architecture pattern. \n\nIt is inspired from [MvRx](https://www.github.com/airbnb/mvrx) and [Roxie](https://github.com/ww-tech/roxie), but unlike them it is **built completely using Kotlin Coroutines** instead of RxJava. As such, it internally only uses Coroutine primitives, and has extensive support for Suspending functions.\n\nVector works well with Android Architecture Components. It is 100% Kotlin, and is intended for use with Kotlin only.\n\n## Building Blocks\n\nVector is based primarily around three classes: `VectorViewModel`, `VectorState`, and `VectorFragment`.\n\n* **VectorViewModel**\n\nThe Vector ViewModel class is the heart of any screen built with Vector. It is an abstract class extending the Android Architecture Components ViewModel class, and therefore survives configuration changes. It is generic on a class implementing the `VectorState` interface. It is also the only class which can mutate state.\n\nIt exposes the current state through a `Kotlin Flow`.\n\n* **VectorState**\n\nVectorState is an interface denoting a model class representing the view's state. We recommend using Kotlin data classes to represent view state in the interest of keeping state immutable. Use the generated `copy()` method to create new state objects.\n\n* **VectorFragment**\n\nVector provides an abstract `VectorFragment` class extending from AndroidX's Fragment class. A `VectorFragment` has a convenient coroutine scope, which can be used to easily launch Coroutines from a Fragment.\n\n## Example\n\nHere's a contrived example to show how an app written in Vector looks like.\n\n\u003e VectorState\n\n```kotlin\ndata class MyState(val message: String): VectorState\n```\n\n\u003e VectorFragment\n\n```kotlin\nclass MyFragment: VectorFragment() {\n\n    private val myViewModel: MyViewModel by fragmentViewModel()\n\n    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {\n        renderState(viewModel) { state -\u003e\n            toast(state.message)\n        }\n    }\n}\n```\n\n\u003e VectorViewModel\n\n```kotlin\nclass MyViewModel(initState: MyState): VectorViewModel\u003cMyState\u003e(initState) {\n\n    init {\n        getMessage()\n    }\n\n    fun getMessage() = setState { \n        copy(message = \"Hello, world!\") \n    }\n}\n```\n\nWhen the `setState()` function is given a state reducer, it internally enqueues it to a Kotlin `Actor`. The reducers passed to this actor are processed sequentially to avoid race conditions.\n\n## Documentation\n\nThe docs can be found at the project's [documentation website](https://haroldadmin.github.io/Vector).\n\n## Projects using Vector\n\n* You can find a [sample app](https://github.com/haroldadmin/Vector/tree/master/sampleapp) along with the library in this repository.\n* [MoonShot](https://www.github.com/haroldadmin/MoonShot) is another project of mine. It's an app to help you keep up with SpaceX launches, and is built with Vector.\n\nIf you would like your project using Vector to be featured here, please open an Issue on the repository. I shall take a look at it and add your project to the list.\n\n## Installation Instructions\n\nAdd the Jitpack repository to your top level `build.gradle` file.\n\n```groovy\nallprojects {\n  repositories {\n    ...\n    maven { url 'https://jitpack.io' }\n  }\n}\n```\n\nAnd then add the following dependency in your module's `build.gradle` file:\n\n```groovy\ndependencies {\n  implementation \"com.github.haroldadmin:Vector:(latest-version)\"\n}\n```\n\nFind the latest **stable release** version on the [Releases](https://github.com/haroldadmin/Vector/releases) page.\n\nLatest release (stable/unstable):\n[![Release](https://jitpack.io/v/haroldadmin/Vector.svg)](https://jitpack.io/#haroldadmin/Vector)\n\n## Contributing\n\nIf you like this project, or are using it in your app, consider starring the repository to show your support.\nContributions from the community are very welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoldadmin%2Fvector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharoldadmin%2Fvector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoldadmin%2Fvector/lists"}