onPreloadData

Function to provide initial data before making a subscription.

This is primarily intended for reading from locally cached data stored on the device. Temporary data storage can be useful as a fallback when API response is slow or when the device is offline. Any exceptions thrown by this function will be silently ignored.

NOTE: This function is called only once when there is no cache for this key.

override fun onPreloadData(): SubscriptionPreloadData<User> = {
// Load from local cache/database
localCache.getUser(userId)
}

See also