Fountain Coroutines static factory

This module provides a Listing component based on a Retrofit Coroutine adapter like this one.

Network Support Listing Creator for paged endpoints

A Listing with Network support for paged endpoints can be created invoking createNetworkListing.

FountainCoroutines.createNetworkListing(
  networkDataSourceAdapter: CoroutineNetworkDataSourceAdapter<out ListResponse<out NetworkValue>>,
  firstPage: Int = FountainConstants.DEFAULT_FIRST_PAGE,
  ioServiceCoroutineDispatcher: CoroutineDispatcher = Dispatchers.IO,
  coroutineScope: CoroutineScope = GlobalScope,
  pagedListConfig: PagedList.Config = FountainConstants.DEFAULT_PAGED_LIST_CONFIG
)

There's only one required structure, CoroutineNetworkDataSourceAdapter<out ListResponse<Value>>, that Fountain uses to handle the paging.

In addition, there are some optional parameters that you can define:

Network Support Listing Creator for not paged endpoints

A Listing with Network support for not paged endpoints can be created invoking createNotPagedNetworkListing.

fun <NetworkValue> createNotPagedNetworkListing(
  notPagedCoroutinePageFetcher: NotPagedCoroutinePageFetcher<out ListResponse<out NetworkValue>>,
  ioServiceCoroutineDispatcher: CoroutineDispatcher = FountainConstants.NETWORK_EXECUTOR.asCoroutineDispatcher(),
  coroutineScope: CoroutineScope = GlobalScope
)

There's only one required structure, NotPagedCoroutinePageFetcher<out ListResponse<Value>>, that Fountain uses to handle the paging.

In addition, there are some optional parameters that you can define:

Cache + Network Support Listing Creator for paged endpoints

A Listing with Cache + Network Support for paged endpoints can be created invoking the createNetworkWithCacheSupportListing

FountainCoroutines.createNetworkWithCacheSupportListing(
  networkDataSourceAdapter: CoroutineNetworkDataSourceAdapter<out ListResponse<out NetworkValue>>,
  cachedDataSourceAdapter: CachedDataSourceAdapter<NetworkValue, DataSourceValue>,
  ioServiceCoroutineDispatcher: CoroutineDispatcher =  Dispatchers.IO,
  ioDatabaseCoroutineDispatcher: CoroutineDispatcher = FountainConstants.DATABASE_EXECUTOR.asCoroutineDispatcher(),
  coroutineScope: CoroutineScope = GlobalScope,
  firstPage: Int = FountainConstants.DEFAULT_FIRST_PAGE,
  pagedListConfig: PagedList.Config = FountainConstants.DEFAULT_PAGED_LIST_CONFIG
)

There are two required components:

  1. A CachedDataSourceAdapter<Value> to take control of the DataSource.

In addition, there are some optional parameters that you can define:

Cache + Network Support Listing Creator for not paged endpoints

A Listing with Cache + Network Support for not paged endpoints can be created invoking the createNotPagedNetworkWithCacheSupportListing

FountainCoroutines.createNotPagedNetworkWithCacheSupportListing(
    notPagedCoroutinePageFetcher: NotPagedCoroutinePageFetcher<out ListResponse<out NetworkValue>>,
    cachedDataSourceAdapter: CachedDataSourceAdapter<NetworkValue, DataSourceValue>,
    ioServiceCoroutineDispatcher: CoroutineDispatcher = FountainConstants.NETWORK_EXECUTOR.asCoroutineDispatcher(),
    ioDatabaseCoroutineDispatcher: CoroutineDispatcher = FountainConstants.DATABASE_EXECUTOR.asCoroutineDispatcher(),
    coroutineScope: CoroutineScope = GlobalScope
)

There are two required components:

  1. A CachedDataSourceAdapter<Value> to take control of the DataSource.

In addition, there are some optional parameters that you can define:

Last updated