teller-android / com.levibostian.teller.cachestate / OnlineCacheState

OnlineCacheState

open class OnlineCacheState<CACHE>

Holds the current state of response that is obtained via a network call. This response structure is meant to be passed out of Teller and to the application using Teller so it can parse it and display the response representation in the app. The online response state is not manipulated here. It is only stored. Data in apps are in 1 of 3 different types of state:

  1. Cache response does not exist. It has never been attempted to be fetched or it has been attempted but failed and needs to be attempted again.
  2. Data has been cached in the app and is either empty or not.
  3. A cache exists, and we are fetching fresh response to update the cache.

Types

Testing

object Testing

Used for testing purposes to create instances of OnlineCacheState.

Properties

cacheData

val cacheData: CACHE?

errorDuringFetch

val errorDuringFetch: Throwable?

errorDuringFirstFetch

val errorDuringFirstFetch: Throwable?

fetchingForFirstTime

val fetchingForFirstTime: Boolean

isFetchingFreshData

val isFetchingFreshData: Boolean

justCompletedSuccessfulFirstFetch

val justCompletedSuccessfulFirstFetch: Boolean

justCompletedSuccessfullyFetchingFreshData

val justCompletedSuccessfullyFetchingFreshData: Boolean

lastTimeFetched

val lastTimeFetched: Date?

noCacheExists

val noCacheExists: Boolean

requirements

val requirements: GetCacheRequirements?

Functions

deliverAllStates

fun deliverAllStates(listener: OnlineCacheStateListener<CACHE>): Unit

Receive the full status of the response.

deliverCacheState

fun deliverCacheState(listener: OnlineCacheStateCacheListener<CACHE>): Unit

This is usually used in the UI of an app to display the cached response to a user.

deliverFetchingFreshCacheState

fun deliverFetchingFreshCacheState(listener: OnlineCacheStateFetchingListener): Unit

This is usually used in the UI of an app to display the status of loading the response type for the first time to a user.

deliverNoCacheState

fun deliverNoCacheState(listener: OnlineCacheStateNoCacheStateListener): Unit

This is usually used in the UI of an app to display that the cached response on the device is empty to a user.

equals

open fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String