Repository

interface Repository<E : Any>

Coordinates a remote NetworkDataSource with a LocalDataSource under a CachePolicy. Mirrors SwiftyNetwork's Repository.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun fetch(endpoint: NetworkEndpoint, cacheKey: CacheKey, policy: CachePolicy = CachePolicy.Default): E

Returns the entity for endpoint, honoring policy against the value cached under cacheKey.

Link copied to clipboard
open fun stream(endpoint: NetworkEndpoint, cacheKey: CacheKey, policy: CachePolicy = CachePolicy.Default): Flow<E>

Observes the entity for endpoint/cacheKey reactively: emits the result of an initial fetch, then re-emits whenever the underlying local store reports a change for cacheKey.

Link copied to clipboard
open fun streamOrNull(endpoint: NetworkEndpoint, cacheKey: CacheKey, policy: CachePolicy = CachePolicy.Default): Flow<E?>

Observes the entity like stream, also emitting null when its local value is removed.