Learn
Learn Ark Data Layer
Understand the boundaries, contracts, observable state, and ownership model behind ark_data_layer.
Learn Ark Data Layer
Ark Data Layer supplies mechanics for concrete Repository implementations. It does not move persistence concerns into the domain or turn DataSourceContainer into an application-wide service locator.
Start with the problem
A catalog feature may read cached records, refresh them from an API, map transport DTOs into domain entities, expose the latest domain snapshot immediately, and notify background consumers after a successful commit. Without a clear boundary, network models leak into business code, several storage clients become an untyped bag, and every Repository invents different observation and shutdown behavior.
Ark Data Layer separates that work into three roles:
Remote / cache / database implementation
implements a narrow DataSource contract
↓
concrete Repository coordinates sources and maps technical data
↓ commit
domain Data is readable synchronously and observable as a Stream
DataSourceContainer belongs to one Repository or one tightly bounded data component. It is constructor wiring for technical sources, not a substitute for application DI.
What the package standardizes
| Concern | Package decision | Application decision |
|---|---|---|
| Source lookup | Exact typed resolution with missing and ambiguity errors | Which source contracts exist |
| Current data | One latest committed value | The immutable domain shape |
| Observation | Replay-latest broadcast Stream | Which consumers subscribe |
| Updates | Explicit setData or updateData commits | Mapping, caching, and concurrency policy |
| Shutdown | Idempotent Repository close | Ownership and order of the wider object graph |
Recommended path
- Getting started builds one small but complete Repository.
- Architecture and boundaries assigns responsibilities to Domain, Data, Application, and Composition layers.
- DataSource contracts explains narrow technical contracts and strict resolution.
- Repository and domain interfaces separates the reusable base from the business-facing abstraction.
- Observable data and lifecycle defines replay, ordering, closing, and ownership.
Continue with Tutorials when you need a complete project flow, or open Recipes for one focused operation.
If you only need to call one client and return its result, a Repository base may add no value. Use Ark Data Layer when the component owns domain-facing current data, coordinates more than a trivial adapter, or needs a consistent observable lifecycle.