ursus
06/13/2021, 9:47 AMclass PermissionManager() {
private val manualTrigger = MutableSharedFlow<Unit>()
...
fun notifyPermissionChanged() {
runBlocking { <---------------------
manualTrigger.emit(Unit)
}
}
}
class Activity {
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
permissionManager.notifyPermissionChanged()
}
}
tryEmit never does anythingBig Chungus
06/13/2021, 9:55 AMursus
06/13/2021, 10:08 AMBig Chungus
06/13/2021, 10:10 AMursus
06/13/2021, 10:12 AMBig Chungus
06/13/2021, 10:13 AMursus
06/13/2021, 10:14 AMBig Chungus
06/13/2021, 10:15 AMursus
06/13/2021, 10:15 AMBig Chungus
06/13/2021, 10:16 AMursus
06/13/2021, 10:16 AMBig Chungus
06/13/2021, 10:16 AMursus
06/13/2021, 10:17 AMBig Chungus
06/13/2021, 10:17 AMursus
06/13/2021, 10:18 AMBig Chungus
06/13/2021, 10:18 AMursus
06/13/2021, 10:19 AMJavier
06/13/2021, 12:16 PMasync(<http://Dispatchers.IO|Dispatchers.IO>) { ... }
you mean suspend
+ withContext(<http://Dispatchers.IO|Dispatchers.IO>) { ... }
? I can't find an async functionBig Chungus
06/13/2021, 12:47 PMJavier
06/13/2021, 2:27 PMBig Chungus
06/13/2021, 2:42 PMursus
06/13/2021, 3:33 PMAdam Powell
06/13/2021, 3:57 PMFrancesc
06/13/2021, 5:51 PMextraBufferCapacity
parameter to ensure the flow will accept your valueursus
06/13/2021, 6:22 PMKamilH
06/14/2021, 5:26 AMval manualTrigger = MutableSharedFlow<Unit>(extraBufferCapacity = 1)
it will let you use MutableSharedFlow.tryEmit
. You can read more about why you need this here:
https://itnext.io/mutablesharedflow-is-kind-of-complicated-61af68011eaeursus
06/14/2021, 8:07 PM