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

LocalCacheState

data class LocalCacheState<CACHE : Any>

Local response (response obtained from the user or device, no network fetch call) in apps are in 1 of 2 different types of state:

  1. It is empty.
  2. It is not empty.

This class takes in a type of cacheData to keep state on via generic CACHE and it maintains the state of that cacheData. It gives you a snapshot of the state of your local response at any given time.

This class is used in companion with LocalRepository and LocalCacheStateBehaviorSubject to maintain the state of cacheData to deliver to someone observing.

Types

Testing

object Testing

Used for testing purposes to create instances of LocalCacheState.

Properties

cacheData

val cacheData: CACHE?

isEmpty

val isEmpty: Boolean

requirements

val requirements: GetCacheRequirements?

Functions

deliverState

fun deliverState(listener: LocalCacheStateListener<CACHE>): Unit

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