-
public final class FlushWorkerWatches for connectivity changes and flushes any cached requests using the provided networkExecutor. Caches requests using JSON Lines format.
-
-
Constructor Summary
Constructors Constructor Description FlushWorker(Context context, SuspendFunction4<String, String, ByteArray, Boolean, String> networkExecutor)
-
Method Summary
Modifier and Type Method Description final Unitstart()Start listening and attempt an immediate flush on init. final Unitstop()Stop the periodic flush timer. final BooleanhasCachedRequests()Check if there are any cached requests remaining final UnitregisterCompletionCallback(SuspendFunction0<Unit> callback)Register a callback to be notified when all cached requests are processed final UnitcacheRequest(CachedRequest req)Append a failed request to the cache file as a single JSON line. final UnitclearCache()Delete all cached requests immediately. -
-
Method Detail
-
start
@RequiresApi(value = 23)@RequiresPermission(value = android.permission.ACCESS_NETWORK_STATE) final Unit start()
Start listening and attempt an immediate flush on init.
-
hasCachedRequests
final Boolean hasCachedRequests()
Check if there are any cached requests remaining
-
registerCompletionCallback
final Unit registerCompletionCallback(SuspendFunction0<Unit> callback)
Register a callback to be notified when all cached requests are processed
-
cacheRequest
final Unit cacheRequest(CachedRequest req)
Append a failed request to the cache file as a single JSON line.
-
clearCache
final Unit clearCache()
Delete all cached requests immediately.
-
-
-
-