Closed LiJianShu0826 closed 2 years ago
Could you clarify what you're trying to do?
lifecycleScope.launch { //1⃣️ exampleCounterFlow.collect { value -> Toast.makeText( this@MainActivity, "$value", Toast.LENGTH_LONG ).show() lifecycleScope.cancel() } }
This should collect the first element then cancel the lifecycle scope. Why are you cancelling the lifecycle scope?
i'm write a demo about preferencesDataStore
The coroutine has bean suspend at 1⃣️. but no resume, so when i transfer
val currentCounterValue = settings[EXAMPLE_COUNTER] ?: 0
at 2⃣️.it will transfercollect
code block again!