arch-event-observer
2.1.0indexedEvent and result observation with DataResult, LiveData/Flow wrappers, chaining/mapping/merge helpers and a Compose-first DSL for declarative loading, data, error and collection handling.
Event and result observation with DataResult, LiveData/Flow wrappers, chaining/mapping/merge helpers and a Compose-first DSL for declarative loading, data, error and collection handling.
Kotlin-first event and result observation for Android and Compose Multiplatform.
The project is split into three public modules:
event-observer for DataResult, ResponseLiveData, ResponseFlow, and the supporting
utilitiesevent-observer-compose for ComposableDataResult and the Compose-facing observation DSLevent-observer-state for serializable SavedStateHandle state, repository operations and projections2.4.209.8.021 via the Gradle toolchainminSdk 23 and The examples on this branch describe the 3.0.0 API, including its new Compose API. For publication status, see GitHub Releases. Use the documentation from the Git tag matching your installed version. See the Compose migration guide.
Version 3.0.0 includes both the Compose API migration and privately owned State keys. Review the state migration and release notes before upgrading.
The library centers on DataResult<T> and a small set of wrappers that keep loading, success,
error, and list-state handling consistent across Android and Compose layers.
Use event-observer when you want:
DataResult helpers and status handlingResponseLiveData, MutableResponseLiveData, and SwapResponseLiveDataResponseFlow, ResponseStateFlow, and Use event-observer-compose when you want:
Use event-observer-state when you want:
SavedStateHandleDataResultPick the module that matches your layer:
dependencies {
implementation("io.github.matheus-corregiari:event-observer:<version>")
}
dependencies {
implementation("io.github.matheus-corregiari:event-observer-compose:<version>")
}
event-observer-compose builds on top of event-observer, so use both only when you need
Compose rendering on top of the base result model.
For saved state in shared code:
kotlin {
sourceSets.commonMain.dependencies {
implementation("io.github.matheus-corregiari:event-observer-state:<version>")
}
}
Apply the Kotlin serialization plugin in the module declaring your @Serializable models.
The state artifact includes the base result API; add the Compose artifact for its rendering DSL.
event-observer
event-observer-compose
ComposableDataResultUse only event-observer when your UI layer is not Compose. Add event-observer-compose when the
final observation point lives inside Jetpack Compose Multiplatform.
The fastest path is to start with DataResult and render it where you need it.
val result = dataResultSuccess("Hello")
result.unwrap {
data { value -> println(value) }
error { throwable -> println(throwable.message) }
loading { isLoading -> println("loading=$isLoading") }
}
For Compose, collect and render the upstream state with Content, selecting the blocks you care
about.
myFlow.Content {
OnShowLoading { CircularProgressIndicator() }
OnData { value -> Text(value.toString()) }
OnError { error -> Text(error.message ?: "Unknown error") }
}
For saved state, declare a shared ViewModel and start a new operation on refresh:
androidx.lifecycle.SavedStateHandle
androidx.lifecycle.ViewModel
br.com.arch.toolkit.eventObserver.state.saveResponseState
br.com.arch.toolkit.result.DataResult
kotlinx.coroutines.flow.Flow
kotlinx.serialization.Serializable
( name: String)
(handle: SavedStateHandle) : ViewModel() {
users handle.saveResponseState<List<User>>()
count = users.select { it?.size ?: }
= users.load { source() }
}
Observe users.flow() from the View. Its last payload survives completed requests and is restored
through the handle's owner. See the state guide for filters,
plain values, mapping and platform restoration limits.
Public docs live in docs/:
The published MkDocs site is built from the same content and mirrors these pages.
event-observer shares result and Flow APIs across KMP targets; LiveData APIs are Android-only.event-observer-compose builds on top of event-observer, Flow, and Compose state.Read CONTRIBUTING.md before sending changes.
Copyright 2025 Matheus Corregiari
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
See event-observer-state for one-shot requests, refresh, filters, continuous streams and transformations. Existing Toolkit consumers should follow the migration guide.
See release notes, dependency versions and coverage configuration. See GitHub Releases for publication status.
compileSdk 37.21.12.1 with iOS ARM targetsResponseSharedFlowDataResultContent and DataResult.Content for snapshot renderingFlow<DataResult<T>>.Content and ComposableDataResult(flow) for collection and renderingOnData, OnError, OnShowLoading, OnEmpty, OnNotEmpty,
OnSingle, and OnManyevent-observerSurfaced from shared tags and platforms — no rankings paid for.