-
Notifications
You must be signed in to change notification settings - Fork 1
add RemoteState #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KuzminVik
wants to merge
3
commits into
icerockdev:main
Choose a base branch
from
KuzminVik:remotestate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| .gradle | ||
| .settings | ||
| .project | ||
| .classpath | ||
| .vscode | ||
| .idea | ||
| .kotlin | ||
| build | ||
| *.iml | ||
| Pods | ||
| xcuserdata | ||
| local.properties | ||
| local.gradle | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Do’s and Don’ts | ||
|
|
||
| * **Search tickets before you file a new one.** Add to tickets if you have new information about the issue. | ||
| * **Keep tickets short but sweet.** Make sure you include all the context needed to solve the issue. Don't overdo it. Great tickets allow us to focus on solving problems instead of discussing them. | ||
| * **Take care of your ticket.** When you spend time to report a ticket with care we'll enjoy fixing it for you. | ||
| * **Use [GitHub-flavored Markdown](https://help.github.com/articles/markdown-basics/).** Especially put code blocks and console outputs in backticks (```` ``` ````). That increases the readability. Bonus points for applying the appropriate syntax highlighting. | ||
|
|
||
| ## Bug Reports | ||
|
|
||
| In short, since you are most likely a developer, provide a ticket that you _yourself_ would _like_ to receive. | ||
|
|
||
| First check if you are using the latest library version and Kotlin version before filing a ticket. | ||
|
|
||
| Please include steps to reproduce and _all_ other relevant information, including any other relevant dependency and version information. | ||
|
|
||
| ## Feature Requests | ||
|
|
||
| Please try to be precise about the proposed outcome of the feature and how it | ||
| would related to existing features. | ||
|
|
||
|
|
||
| ## Pull Requests | ||
|
|
||
| We **love** pull requests! | ||
|
|
||
| All contributions _will_ be licensed under the Apache 2 license. | ||
|
|
||
| Code/comments should adhere to the following rules: | ||
|
|
||
| * Names should be descriptive and concise. | ||
| * Use four spaces and no tabs. | ||
| * Remember that source code usually gets written once and read often: ensure | ||
| the reader doesn't have to make guesses. Make sure that the purpose and inner | ||
| logic are either obvious to a reasonably skilled professional, or add a | ||
| comment that explains it. | ||
| * Please add a detailed description. | ||
|
|
||
| If you consistently contribute improvements and/or bug fixes, we're happy to make you a maintainer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # Mobile Kotlin RemoteState | ||
|
|
||
| A Kotlin Multiplatform library for managing remote state in your Android, iOS, and Web applications. | ||
|
|
||
| ## Overview | ||
|
|
||
| Moko RemoteState provides a simple and efficient way to handle remote data states with Kotlin's coroutines and Flow. It's designed for multiplatform projects, allowing you to share state management logic across iOS, Android, and Web platforms. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Multiplatform support**: Works on Android, iOS, and Web | ||
| - **Coroutines & Flow**: Built on Kotlin coroutines and Flow for reactive programming | ||
| - **Simple API**: Easy to use with intuitive state representation | ||
| - **Type-safe**: Compile-time safe state transitions | ||
| - **Zero dependencies**: Pure Kotlin implementation | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Gradle Setup | ||
|
|
||
| Add the dependency to your common source set: | ||
|
|
||
| ```kotlin | ||
| implementation("dev.icerock.moko:remotestate:[latestVersion]") | ||
| ``` | ||
|
|
||
| ### Usage | ||
|
|
||
| ```kotlin | ||
| import dev.icerock.moko.remotestate.RemoteState | ||
|
|
||
| // Define your state | ||
| val state = MutableStateFlow<RemoteState<Data, Error>>(Loading) | ||
|
|
||
| // Update state | ||
| state.value = Success(Data("Hello, World!")) | ||
|
|
||
| // Map success | ||
| val mappedState = state.mapSuccess { it.uppercase() } | ||
|
|
||
| // Check state | ||
| if (state.isSuccess()) { | ||
| println(state.data) | ||
| } | ||
| ``` | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### RemoteState | ||
|
|
||
| A sealed class representing the state of remote data. | ||
|
|
||
| - `Loading` - Represents an ongoing operation | ||
| - `Success<T>` - Contains successfully loaded data | ||
| - `Error<E>` - Contains an error occurred during operation | ||
|
|
||
| ### Functions | ||
|
|
||
| - `mapSuccess` - Transform data in Success state | ||
| - `mapError` - Transform error in Error state | ||
| - `isLoading` - Check if state is loading | ||
| - `isSuccess` - Check if state is successful | ||
| - `tryUpdateSuccess` - Atomically update data in Success state | ||
|
|
||
| ## Contributing | ||
| All development (both new features and bug fixes) is performed in the `develop` branch. This way `master` always contains the sources of the most recently released version. Please send PRs with bug fixes to the `develop` branch. Documentation fixes in the markdown files are an exception to this rule. They are updated directly in `master`. | ||
|
|
||
| The `develop` branch is pushed to `master` on release. | ||
|
|
||
| For more details on contributing please see the [contributing guide](CONTRIBUTING.md). | ||
|
|
||
| ## License | ||
|
|
||
| Apache 2.0 License - see [LICENSE](LICENSE) file for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| plugins { | ||
| `kotlin-dsl` | ||
| } | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| google() | ||
|
|
||
| gradlePluginPortal() | ||
| } | ||
|
|
||
| dependencies { | ||
| api(libs.nexusPublishing) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright 2026 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
| */ | ||
|
|
||
| rootProject.name = "build-logic" | ||
|
|
||
| dependencyResolutionManagement { | ||
| repositories { | ||
| mavenCentral() | ||
| google() | ||
| } | ||
|
|
||
| versionCatalogs { | ||
| create("libs") { | ||
| from(files("../gradle/libs.versions.toml")) | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
build-logic/src/main/kotlin/nexus-publication-convention.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * Copyright 2026 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
| */ | ||
|
|
||
| import java.net.URI | ||
|
|
||
| plugins { | ||
| id("io.github.gradle-nexus.publish-plugin") | ||
| } | ||
|
|
||
| nexusPublishing { | ||
| repositories { | ||
| // TODO() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need now? |
||
| sonatype { | ||
| nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) | ||
| snapshotRepositoryUrl.set(URI.create("https://central.sonatype.com/repository/maven-snapshots/")) | ||
| username.set(System.getenv("OSSRH_USER")) | ||
| password.set(System.getenv("OSSRH_KEY")) | ||
| } | ||
| } | ||
| } | ||
57 changes: 57 additions & 0 deletions
57
build-logic/src/main/kotlin/publication-convention.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Copyright 2026 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
| */ | ||
|
|
||
| import java.util.Base64 | ||
|
|
||
| plugins { | ||
| id("org.gradle.maven-publish") | ||
| } | ||
|
|
||
| publishing { | ||
| publications.withType<MavenPublication> { | ||
| // Provide artifacts information requited by Maven Central | ||
| pom { | ||
| name.set("MOKO state") | ||
| description.set("Resources access for Kotlin Multiplatform development (mobile first)") | ||
| url.set("https://github.com/icerockdev/moko-state") | ||
| licenses { | ||
| license { | ||
| name.set("Apache-2.0") | ||
| distribution.set("repo") | ||
| url.set("https://github.com/icerockdev/moko-state/blob/master/LICENSE.md") | ||
| } | ||
| } | ||
|
|
||
| developers { | ||
| // TODO() | ||
| } | ||
|
|
||
| scm { | ||
| connection.set("scm:git:ssh://github.com/icerockdev/moko-state.git") | ||
| developerConnection.set("scm:git:ssh://github.com/icerockdev/moko-state.git") | ||
| url.set("https://github.com/icerockdev/moko-state") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| val signingKeyId: String? = System.getenv("SIGNING_KEY_ID") | ||
| if (signingKeyId != null) { | ||
| apply(plugin = "signing") | ||
|
|
||
| configure<SigningExtension> { | ||
| val signingPassword: String? = System.getenv("SIGNING_PASSWORD") | ||
| val signingKey: String? = System.getenv("SIGNING_KEY")?.let { base64Key -> | ||
| String(Base64.getDecoder().decode(base64Key)) | ||
| } | ||
|
|
||
| useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) | ||
| sign(publishing.publications) | ||
| } | ||
|
|
||
| val signingTasks = tasks.withType<Sign>() | ||
| tasks.withType<AbstractPublishToMaven>().configureEach { | ||
| dependsOn(signingTasks) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright 2026 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
| */ | ||
|
|
||
| buildscript { | ||
| repositories { | ||
| mavenCentral() | ||
| google() | ||
| gradlePluginPortal() | ||
| } | ||
|
|
||
| dependencies { | ||
| classpath(libs.kotlinGradlePlugin) | ||
| classpath(libs.androidGradlePlugin) | ||
| classpath(libs.mokoGradlePlugin) | ||
| classpath(libs.mobileMultiplatformGradlePlugin) | ||
| classpath(":build-logic") | ||
| } | ||
| } | ||
|
|
||
| val mokoVersion = libs.versions.mokoStateVersion.get() | ||
|
|
||
| allprojects { | ||
| plugins.withId("org.gradle.maven-publish") { | ||
| group = "dev.icerock.moko" | ||
| version = mokoVersion | ||
| } | ||
| } | ||
|
|
||
| // required for nexus plugin | ||
| group = "dev.icerock.moko" | ||
| version = mokoVersion | ||
|
|
||
| apply(plugin = "nexus-publication-convention") | ||
|
|
||
| tasks.register("clean", Delete::class).configure { | ||
| delete(rootProject.buildDir) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| org.gradle.jvmargs=-Xmx4096m | ||
| org.gradle.configureondemand=false | ||
| org.gradle.parallel=true | ||
|
|
||
| kotlin.code.style=official | ||
|
|
||
| moko.android.targetSdk=35 | ||
| moko.android.compileSdk=35 | ||
| moko.android.minSdk=16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [versions] | ||
| kotlinVersion = "2.1.10" | ||
| coroutinesVersion = "1.10.2" | ||
| mokoStateVersion = "0.1.0" | ||
|
|
||
| [libraries] | ||
| coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutinesVersion" } | ||
| coroutinesTest = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutinesVersion" } | ||
|
|
||
| kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" } | ||
| androidGradlePlugin = { module = "com.android.tools.build:gradle", version = "8.0.2" } | ||
| mokoGradlePlugin = { module = "dev.icerock.moko:moko-gradle-plugin", version = "0.3.0" } | ||
| mobileMultiplatformGradlePlugin = { module = "dev.icerock:mobile-multiplatform", version = "0.14.4" } | ||
| nexusPublishing = { module = "io.github.gradle-nexus:publish-plugin", version = "2.0.0" } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.