GenericRepository
The default Repository: reads/writes a LocalDataSource and falls through to the network per CachePolicy, always writing through to local storage on a successful network load. Mirrors SwiftyNetwork's GenericRepository.
Concurrent loads for the same CacheKey are coalesced: a burst of callers that all miss the cache triggers a single network request whose result they all await — the same single-flight pattern the network layer uses for token refresh.
Parameters
coroutine scope hosting the coalesced loads. Pass your own to tie loads to a lifecycle you control; when omitted, an internal SupervisorJob on Dispatchers.Default is created and close cancels it. close never cancels a scope you supplied, and a failed load never cancels it either — its failure is delivered only to the callers awaiting it.
Prefer the reified GenericRepository(networkDataSource, localDataSource) factory below, which captures responseType for you.
Constructors
Functions
Observes the entity for endpoint/cacheKey reactively: emits the result of an initial fetch, then re-reads cacheKey whenever the underlying local store reports a change. Intermediate values may be conflated; unchanged values are not emitted by GenericRepository.
Observes the entity like stream, also emitting null when its local value is removed.