Andoroid MVI Example: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
Line 7: Line 7:
[[File:MVI2a.png|700px]]<br>
[[File:MVI2a.png|700px]]<br>
=Setup=
=Setup=
Like this, as I never knew you could do this, don't do it at work but safe for home I guess. For Orbit MVI we add
Like this, as I never knew you could do this to get the latest version, don't do it at work but safe for home I guess. For Orbit MVI we add
<syntaxhighlight lang="kts">
<syntaxhighlight lang="kts">
implementation("org.orbit-mvi:orbit-core:<latest-version>")
implementation("org.orbit-mvi:orbit-core:<latest-version>")
Line 13: Line 13:
implementation("org.orbit-mvi:orbit-compose:<latest-version>")
implementation("org.orbit-mvi:orbit-compose:<latest-version>")
testImplementation("org.orbit-mvi:orbit-test:<latest-version>")
testImplementation("org.orbit-mvi:orbit-test:<latest-version>")
</syntaxhighlight>
And for Ktor
<syntaxhighlight lang="kts">
runtimeOnly("io.ktor:ktor-client-core:<latest-version>")
runtimeOnly("io.ktor:ktor-client-content-negotiation-jvm:<latest-version>")
runtimeOnly("io.ktor:ktor-client-android:<latest-version>")
runtimeOnly("io.ktor:ktor-serialization-kotlinx-json:<latest-version>")
</syntaxhighlight>
</syntaxhighlight>

Revision as of 23:47, 7 March 2025

Introduction

Wanted to revisit the MVI pattern to just have another look using another approach this example uses ktor, an asyncronous client, where I was previously using Retrofit, and Oribit MVI which provides the container and the Store elements. (See Below)

The Pattern

Last time I looked at this we had this diagram

For this example I will be using this one

Setup

Like this, as I never knew you could do this to get the latest version, don't do it at work but safe for home I guess. For Orbit MVI we add

implementation("org.orbit-mvi:orbit-core:<latest-version>")
implementation("org.orbit-mvi:orbit-viewmodel:<latest-version>")
implementation("org.orbit-mvi:orbit-compose:<latest-version>")
testImplementation("org.orbit-mvi:orbit-test:<latest-version>")

And for Ktor

runtimeOnly("io.ktor:ktor-client-core:<latest-version>")
runtimeOnly("io.ktor:ktor-client-content-negotiation-jvm:<latest-version>")
runtimeOnly("io.ktor:ktor-client-android:<latest-version>")
runtimeOnly("io.ktor:ktor-serialization-kotlinx-json:<latest-version>")