repository-flow-conventions

Installation
SKILL.md

Repository method shapes

Pick the shape by where the data comes from, not by what is convenient at the call site. Four shapes cover everything a repository over a database and a network API does:

Kind of method Shape Why this one
One-shot local read flow { emit(local.x()) }.flowOn(IO) one value, computed lazily on first collection, off the caller's thread
Live local read the database's own Flow, returned unchanged the database library already re-emits on every write and already confines the query
Remote read flow { api.x().onSuccess { emit(Success(map(it))) }.onFailure { emit(Error(msg)) } }.flowOn(IO) a call that can fail needs somewhere to put the failure
Write suspend fun … = withContext(IO) { local.x() } nothing to observe; the caller awaits completion
Installs
2
GitHub Stars
35
First Seen
6 days ago
repository-flow-conventions — maxrave-dev/kotlin-footguns