to some “no-op” value to avoid having a nullable type?
Troy Perales
04/19/2024, 1:22 AM
The best I could come up with is
var job = scope.launch {}
j
jw
04/19/2024, 1:27 AM
null
seems a pretty good candidate though.
You can also just call
Job()
to get an active-yet-detached instance.
t
Troy Perales
04/19/2024, 1:33 AM
Would you say it’s still a good candidate in the context of a Compose function where I lose out on smart casting and have to copy it?
Copy code
var inactiveTimeout: Job? by rememberRetained { mutableStateOf(null) }
...
//"Smart cast to 'Job' is impossible.."
if (inactiveTimeout != null && !inactiveTimeout.isActive) {
...
Maybe it’s just my aversion to safe calls I need to get over. Seen too many apps with them littered all over.
j
jw
04/19/2024, 1:37 AM
Seems like it could go either way based on your preference then, yeah.