getBestSupplier static method

Future<ProductListSupplier> getBestSupplier(
  1. PagedProductQuery productQuery,
  2. LocalDatabase localDatabase
)

Returns the fastest data supplier: database if possible, or server query

Implementation

static Future<ProductListSupplier> getBestSupplier(
  PagedProductQuery productQuery,
  LocalDatabase localDatabase,
) async {
  final int? timestamp = await DaoProductList(
    localDatabase,
  ).getTimestamp(productQuery.getProductList());
  return timestamp == null
      ? QueryProductListSupplier(productQuery, localDatabase)
      : DatabaseProductListSupplier(productQuery, localDatabase, timestamp);
}