Issue
As launchWhenStarted and repeatOnLifecycle(STARTED) provide completely different functionality (launchWhenStarted suspends the execution of the coroutine, and repeatOnLifecycle cancels and restarts a new coroutine), if the names of the new APIs were similar (for example, using launchWhenever for the restarting APIs), developers could’ve got confused and even use them interchangeably without noticing.
What is a simpler explanation for when to use which?
Solution
launchWhenStarted is just a one time delay.
repeatOnLifecycle creates a suspending point that acts as a handler that runs provided block every time lifecycle enters provided state and cancel it whenever it falls below it (so for STARTED it happens when it gets stopped).
Answered By - Pawel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.