Skip to content

Instantly share code, notes, and snippets.

View GabrielBrasileiro's full-sized avatar
💭
In my hands the means, In my heart the will

Gabriel Brasileiro GabrielBrasileiro

💭
In my hands the means, In my heart the will
View GitHub Profile
@GabrielBrasileiro
GabrielBrasileiro / HighOrderFunctionInline.kt
Last active June 21, 2021 20:12
HighOrderFunctionInline.kt
fun main() {
val descricao = "Inline te dando poderes mágicos"
executarOperacao {
print(descricao)
}
}
fun executarOperacao(operacaoDois: () -> Unit) {
operacaoUm()
operacaoDois()
@GabrielBrasileiro
GabrielBrasileiro / SampleActivity.kt
Created June 3, 2020 14:34
Get the ViewModel instance with a simple way
class SampleActivity : AppCompatActivity(R.layout.activity_sample) {
private val viewModel by getViewModel { SampleViewModel(SingleLiveEvent()) }
...
}
@GabrielBrasileiro
GabrielBrasileiro / ComponentCallbacksExtensions.kt
Last active February 25, 2026 01:02
Koin extensions to solve type erasure of generic mappers
/**
* This will recover and inject your interface in your fragments or activities
*/
inline fun <reified I, reified O> ComponentCallbacks.injectMapper(): Lazy<Mapper<I, O>> {
return inject(named(identifier<I, O>()))
}