teller / com.levibostian.teller.cachestate / OnlineDataState

OnlineDataState

data class OnlineDataState<CACHE : Any>

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

  1. Cache data 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 data to update the cache.

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: GetDataRequirements?

Functions

deliverAllStates

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

Receive the full status of the data.

deliverCacheState

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

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

deliverFetchingFreshCacheState

fun deliverFetchingFreshCacheState(listener: OnlineDataStateFetchingListener): Unit

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

deliverNoCacheState

fun deliverNoCacheState(listener: OnlineDataStateNoCacheStateListener): Unit

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

equals

fun equals(other: Any?): Boolean

hashCode

fun hashCode(): Int

toString

fun toString(): String