Please enable JavaScript.
Coggle requires JavaScript to display documents.
WORK MANAGER /PERSISTENT WORK, image - Coggle Diagram
WORK MANAGER
/PERSISTENT WORK
REF
https://www.youtube.com/watch?v=A2JetouoNSc
deferrable background work
https://www.youtube.com/watch?v=IrKoBFLwTN0&t=1s
https://youtu.be/IrKoBFLwTN0?t=726s
SHERLOCK MOST USED WORD COUNTER
https://aish05.medium.com/periodic-workmanager-and-kotlin-coroutines-51ae89c0ec26
TYPES
PERIODIC WORK/DEFERRABLE
EXAMPLES
PERIODICALLY SYNC LOCAL DATA WITH NETWORK
UPLOADING LOGS /FILES
USER DON'T NEED STAY IN THE APP
OFF-LINE APPS SYNC
:star:
STARTS LATER
RUNS PERIODICALLY
E.G
ONE HOUR INTERVAL
MIN 15 MINUTES
15 MIN EVERY ONE HOUR PERIOD
EXPEDITED WORK/IMMEDIATE
SCHEDULE EXPEDITED WORK
Link
LONG RUNNING
+10 MINUTES
E.G
TESTING
https://youtu.be/IrKoBFLwTN0?t=1627s
CONCEPT
BACKGROUND PROCESSING
PERSISTENT WORK
WORK RUN RELIABLY
USER NAVIGATES OFF SCREEN
APP EXITS
DEVICE RESTARS
BEST PRACTICES
https://youtu.be/IrKoBFLwTN0?t=1722s
REPLACE DEPRECATED APIs
FirebaseJobDispatcher
GcmNetworkManager
Job Scheduler
GETTING STARTED
implementation("androidx.work:work-runtime-ktx:$work_version")
LAST RELEASE
define the work
create a workRequest
Submit the workRequest to the sys
DEFINE WORK REQUESTS
customize WrokRequest objects
QUOTAS
policies
CoroutineWorker
WORK CONSTRAINTS
.setInitialDelay
.setBackoffCriteria - (Retry and backoff policy)
DEFAULT
EXPONENTIAL AND 30 SECONDS
https://youtu.be/O9_RSYSmeIE?t=679s
recuo
when worker fails and handle how to retry
SEEMS LIKE NOT WORKING WITH PeriodicWorkRequestBuilder :warning:
TAG WORK
ASSIGN INPUT DATA
UNIQUE WORK
CONFLICT RESOLUTION POLICY
https://youtu.be/IrKoBFLwTN0?t=1246s
COMPLEX WORK QUERIES
STOP A RUNNING WORKER
CHAINING WORK
;beginWith / .then
input mergers
https://youtu.be/IrKoBFLwTN0?t=868s
OBSERVE INTERMEDIATE PROGRESS
UPDATE WORK
THREADING TOPIC
CONFIGURATIONS
ON-DEMAND INITIALIZATION
Configuration.Builder
DATA LAYER IMPL
SCHEDULE TASKS USING WORKMANAGER
:star:
CoroutineWorker
Similar to the Worker class, In kotlin we have a CoroutineWorker which differs from the Worker class is that the doWork() method in a CoroutineWorker is a suspend function and can run asynchronous tasks, while Worker’s doWork() can only execute synchronous tasks
10 MINUTES ONLY
A CoroutineWorker is given a maximum of ten minutes to finish its execution and return a [ListenableWorker.Result]. After this time has expired, the worker will be signalled to stop.
Battery Optimisation checks
Inject WorkManager with Hilt
HiltWork
_@HiltWorker
REF
https://www.youtube.com/watch?v=O9_RSYSmeIE