All Projects → orbit-mvi → orbit-mvi

orbit-mvi / orbit-mvi

Licence: other
A simple MVI framework for Kotlin Multiplatform and Android

Programming Languages

kotlin
9241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to orbit-mvi

Pagination-MVI-Flow
Pagination MVI Coroutines Flow. Play MVI with Kotlin Coroutines Flow | MVI pattern on Android using Kotlin Coroutines Flow | Dagger Hilt DI | SharedFlow | StateFlow
Stars: ✭ 45 (-86.53%)
Mutual labels:  mvi, mvi-android, mvi-coroutines-flow, mvi-coroutines-flow-kotlin
weather-app-2020-android
Android Weather App 2020
Stars: ✭ 15 (-95.51%)
Mutual labels:  mvi, mvi-android
StarWarsSearch-MVI
Star wars sample android project showcasing the use of View components for rendering UI in Fragments and Activities. Uses Android Jetpack, clean architecture with MVI (Uni-directional data flow), dagger hilt, and kotlin coroutines with StateFlow
Stars: ✭ 189 (-43.41%)
Mutual labels:  mvi, mvi-android
WeatherApp MVI sample
🌸[Functional reactive programming (FRP)] 🍁Simple Android weather forecast application written in Kotlin, using RxKotlin, Retrofit2, Mosby, Room Persistence ❄️MVI Pattern with Mosby Library
Stars: ✭ 106 (-68.26%)
Mutual labels:  mvi, mvi-android
UI-Communication-with-MVI
Effective UI Communication with MVI architecture, a BaseActivity and the Repository Pattern.
Stars: ✭ 17 (-94.91%)
Mutual labels:  mvi, mvi-android
fluxy
Fluxy is a Flux architecture implementation written in Kotlin.
Stars: ✭ 25 (-92.51%)
Mutual labels:  mvi, mvi-android
Reaktor
👾 A Framework for reactive and unidirectional Kotlin application archtitecture with RxJava2.
Stars: ✭ 16 (-95.21%)
Mutual labels:  mvi
Tracktor-ComposeUI
Track the progress of anything in one place
Stars: ✭ 25 (-92.51%)
Mutual labels:  mvi
Awesome-Android-Open-Source-Projects
👓 A curated list of awesome android projects by open-source contributors.
Stars: ✭ 401 (+20.06%)
Mutual labels:  mvi
MVI-Architecture-Android-Beginners
This repository contains a beginner sample app that implements MVI architecture
Stars: ✭ 199 (-40.42%)
Mutual labels:  mvi
News-Feed-App
Simple news feed app for Android, built with sort of MVI + Clean Architecture
Stars: ✭ 14 (-95.81%)
Mutual labels:  mvi
Lastik
Kotlin Multiplatform + Jetpack Compose pet project, based on www.last.fm/api (in development)
Stars: ✭ 37 (-88.92%)
Mutual labels:  mvi
eosreach-android
An EOS wallet developed in Kotlin using the eos-jvm SDK and the model view intent (MVI) design pattern. This wallet serves as a blueprint for how other developers might want to utilise eos-jvm to develop native Android apps that consume the EOS blockchain.
Stars: ✭ 37 (-88.92%)
Mutual labels:  mvi
kmm
Rick & Morty Kotlin Multiplatform Mobile: Ktor, Sqldelight, Koin, Flow, MVI, SwiftUI, Compose
Stars: ✭ 52 (-84.43%)
Mutual labels:  mvi
Artic
A take on dynamic feature modularization, kotlin coroutines, MVI and unidirectional data flow. WIP
Stars: ✭ 47 (-85.93%)
Mutual labels:  mvi
MVI-Clean-Architecture
MVI + Clean Architecture + Best Practices | Example of Clean Architecture of Android app using MVI design pattern with Jetpack and popular libraries
Stars: ✭ 50 (-85.03%)
Mutual labels:  mvi-android
JsonPlaceholderApp
This was originally a code challenge for a company, but now is an example of MVI on Android.
Stars: ✭ 26 (-92.22%)
Mutual labels:  mvi
android-mvi
Android MVI design pattern in Kotlin
Stars: ✭ 57 (-82.93%)
Mutual labels:  mvi
Android-MVI-Clean-Arch-Sample
A Simple Android Project demonstrating Clean Arch + MVI with https://api.nasa.gov/api.html#apod as use-case example
Stars: ✭ 20 (-94.01%)
Mutual labels:  mvi
Keemun
No description or website provided.
Stars: ✭ 13 (-96.11%)
Mutual labels:  mvi

Orbit Multiplatform

CI status codecov Download License

Logo

Get in touch

slack logo twitter logo

What is Orbit

Orbit is a Redux/MVI-like library - but without the baggage. It's so simple we think of it as MVVM+.

  • Simple, type-safe, coroutine-style, extensible API
  • Multiplatform, targetting Android and iOS (iOS support is in alpha and being actively worked on)
  • Full support for Kotlin Coroutines (it's built on top of them after all)
  • Lifecycle-safe collection of infinite flows
  • ViewModel support, along with SavedState
  • Optional, simple unit test library
  • Built-in espresso idling resource support
  • Compatible with RxJava, LiveData etc. through coroutine wrappers
  • And more...

Documentation

Articles & Talks

Getting started

Download

implementation("org.orbit-mvi:orbit-core:<latest-version>")
// or, if on Android:
implementation("org.orbit-mvi:orbit-viewmodel:<latest-version>")

// Tests
testImplementation("org.orbit-mvi:orbit-test:<latest-version>")

Define the contract

data class CalculatorState(
    val total: Int = 0
)

sealed class CalculatorSideEffect {
    data class Toast(val text: String) : CalculatorSideEffect()
}

Create the ViewModel

  1. Implement the ContainerHost interface
  2. Override the container field and use the ViewModel.container factory function to build an Orbit Container in your ContainerHost
class CalculatorViewModel: ContainerHost<CalculatorState, CalculatorSideEffect>, ViewModel() {

    // Include `orbit-viewmodel` for the factory function
    override val container = container<CalculatorState, CalculatorSideEffect>(CalculatorState())

    fun add(number: Int) = intent {
        postSideEffect(CalculatorSideEffect.Toast("Adding $number to ${state.total}!"))

        reduce {
            state.copy(total = state.total + number)
        }
    }
}

We have used an Android ViewModel as the most common example, but there is no requirement to do so.

Connect to the ViewModel in your Activity or Fragment

class CalculatorActivity: AppCompatActivity() {

    // Example of injection using koin, your DI system might differ
    private val viewModel by viewModel<CalculatorViewModel>()

    override fun onCreate(savedState: Bundle?) {
        ...

        addButton.setOnClickListener { viewModel.add(1234) }

        viewModel.observe(state = ::render, sideEffect = ::handleSideEffect)
    }

    private fun render(state: CalculatorState) {
        ...
    }

    private fun handleSideEffect(sideEffect: CalculatorSideEffect) {
        when (sideEffect) {
            is CalculatorSideEffect.Toast -> toast(sideEffect.text)
        }
    }
}

With Jetpack Compose wire up the ViewModel as follows:

@Composable
fun CalculatorScreen(viewModel: CalculatorViewModel) {

    val state = viewModel.collectAsState().value

    viewModel.collectSideEffect { handleSideEffect(it) }

    // render UI using data from 'state'
    ...
}

private fun handleSideEffect(sideEffect: CalculatorSideEffect) {
    when (sideEffect) {
        is CalculatorSideEffect.Toast -> toast(sideEffect.text)
    }
}

Contributing

Please read contributing for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

License

This project is licensed under the Apache License, Version 2.0 - see the license file for details

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