network Bound Resource
A helper function for managing data that comes from both a local database and a remote network source. This function determines whether to fetch data from the network or use cached data in the database.
Return
A Flow emitting Resource objects, representing the state of the data: - Resource.Loading: Emitted when a network request is in progress. - Resource.Success: Emitted when data is successfully loaded from the database or network. - Resource.Error: Emitted when an error occurs during the network fetch, with the current database data.
Parameters
The type of the data retrieved from the local database.
The type of the data retrieved from the remote network source.
A lambda function that provides a Flow of the data from the local database.
A suspend function that fetches data from the remote network source.
A suspend function that saves the fetched data into the local database.
A lambda function that determines whether to fetch data from the network. By default, it always returns true.