Skip to content

Instantly share code, notes, and snippets.

View davidHarush's full-sized avatar
😎
I may be slow to respond.

davidHarush

😎
I may be slow to respond.
View GitHub Profile
@davidHarush
davidHarush / ViewModelExtension.kt
Created December 30, 2024 13:37
Simplify coroutine management in Android ViewModels with extensions that launch IO-bound tasks, handle errors centrally, and return results on the Main thread. Includes utility functions for ViewModel and AndroidViewModel.
fun <T> ViewModel.launchIoCoroutine(
block: suspend () -> T
) {
viewModelScope.launch(Dispatchers.IO + getExceptionHandler()) {
block()
}
}
@davidHarush
davidHarush / ApplyTextColor.kt
Last active November 24, 2024 20:34
ApplyTextColor Composable Function
@Composable
fun ApplyTextColor( color: Color , content: @Composable () -> Unit) {
CompositionLocalProvider(LocalContentColor provides color) {
content()
}
}
// Example Usage
@Composable
fun ExampleUsage() {