All Projects → haroldadmin → Vector

haroldadmin / Vector

Licence: apache-2.0
Kotlin Coroutines based MVI architecture library for Android

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Vector

Kotlintutorial
Learn Kotlin programming from scratch
Stars: ✭ 88 (-54.64%)
Mutual labels:  kotlin-coroutines
Diveintokotlincoroutines Sources
《深入理解 Kotlin 协程》源码
Stars: ✭ 119 (-38.66%)
Mutual labels:  kotlin-coroutines
Moonshot
A SpaceX companion app for Android
Stars: ✭ 150 (-22.68%)
Mutual labels:  kotlin-coroutines
Gligar
📸Image Picker for Android, Pick an image from Gallery or Capture a new image with Camera.
Stars: ✭ 96 (-50.52%)
Mutual labels:  kotlin-coroutines
Cameraxdemo
A sample camera app with CameraX API from Android Jetpack
Stars: ✭ 112 (-42.27%)
Mutual labels:  kotlin-coroutines
Modular App Core
Core implementations for a modular Android App
Stars: ✭ 127 (-34.54%)
Mutual labels:  kotlin-coroutines
Kuroba Experimental
Free and open source image board browser
Stars: ✭ 76 (-60.82%)
Mutual labels:  kotlin-coroutines
Android Clean Arch Coroutines Koin
Implemented by Clean Architecture, MVVM, Koin, Coroutines, Moshi, Mockk, LiveData & DataBinding
Stars: ✭ 173 (-10.82%)
Mutual labels:  kotlin-coroutines
Kotlin Coroutine Use Cases On Android
🎓 Learning Kotlin Coroutines for Android by example. 🚀 Sample implementations for real-world Android use cases. 🛠 Unit tests included!
Stars: ✭ 1,722 (+787.63%)
Mutual labels:  kotlin-coroutines
Hiya Hiya Hiya
Whatsapp Clone base on Firebase Cloud Messaging
Stars: ✭ 139 (-28.35%)
Mutual labels:  kotlin-coroutines
Android Coroutines
Additional coroutine support for Android
Stars: ✭ 105 (-45.88%)
Mutual labels:  kotlin-coroutines
Kotlincoroutinesexamples
Kotlin Coroutines Examples
Stars: ✭ 109 (-43.81%)
Mutual labels:  kotlin-coroutines
Splitties
A collection of hand-crafted extensions for your Kotlin projects.
Stars: ✭ 1,945 (+902.58%)
Mutual labels:  kotlin-coroutines
Covid 19 Tracker
Android app to track COVID-19 cases in India and globally.
Stars: ✭ 96 (-50.52%)
Mutual labels:  kotlin-coroutines
Notzz App
📝 A Simple Note-Taking App built to demonstrate the use of Modern Android development tools - (Kotlin, Coroutines, State Flow, Hilt-Dependency Injection, Jetpack DataStore, Architecture Components, MVVM, Room, Material Design Components).
Stars: ✭ 158 (-18.56%)
Mutual labels:  kotlin-coroutines
Asynkio
Write your asynchronous Network / IO call painlessly in Kotlin !!
Stars: ✭ 82 (-57.73%)
Mutual labels:  kotlin-coroutines
Androidcoroutinesplayground
Android Coroutines Playground
Stars: ✭ 119 (-38.66%)
Mutual labels:  kotlin-coroutines
Droid Feed
Aggregated Android news, articles, podcasts and conferences about Android Development
Stars: ✭ 174 (-10.31%)
Mutual labels:  kotlin-coroutines
Androidbaseframemvvm
Android 组件化 MVVM 框架 基于 Jetpack + Kotlin
Stars: ✭ 169 (-12.89%)
Mutual labels:  kotlin-coroutines
Coinverse
Coinverse Open App is the first audiocast app for cryptocurrency news. 🚀
Stars: ✭ 133 (-31.44%)
Mutual labels:  kotlin-coroutines

Vector

logo

Build and Test

Vector is an Android library to help implement the MVI architecture pattern.

It is inspired from MvRx and 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.

Vector works well with Android Architecture Components. It is 100% Kotlin, and is intended for use with Kotlin only.

Building Blocks

Vector is based primarily around three classes: VectorViewModel, VectorState, and VectorFragment.

  • VectorViewModel

The 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.

It exposes the current state through a Kotlin Flow.

  • VectorState

VectorState 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.

  • VectorFragment

Vector 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.

Example

Here's a contrived example to show how an app written in Vector looks like.

VectorState

data class MyState(val message: String): VectorState

VectorFragment

class MyFragment: VectorFragment() {

    private val myViewModel: MyViewModel by fragmentViewModel()

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        renderState(viewModel) { state ->
            toast(state.message)
        }
    }
}

VectorViewModel

class MyViewModel(initState: MyState): VectorViewModel<MyState>(initState) {

    init {
        getMessage()
    }

    fun getMessage() = setState { 
        copy(message = "Hello, world!") 
    }
}

When 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.

Documentation

The docs can be found at the project's documentation website.

Projects using Vector

  • You can find a sample app along with the library in this repository.
  • MoonShot is another project of mine. It's an app to help you keep up with SpaceX launches, and is built with Vector.

If 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.

Installation Instructions

Add the Jitpack repository to your top level build.gradle file.

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

And then add the following dependency in your module's build.gradle file:

dependencies {
  implementation "com.github.haroldadmin:Vector:(latest-version)"
}

Find the latest stable release version on the Releases page.

Latest release (stable/unstable): Release

Contributing

If you like this project, or are using it in your app, consider starring the repository to show your support. Contributions from the community are very welcome.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].