Hey everyone... I'd like to see what you think abo...
# koin-contributors
h
Hey everyone... I'd like to see what you think about it. I share the same idea, that's why I'm sending it here 🙂
@Sean McQuillan [G] I'd just add just a lazy return.
Copy code
@Composable
inline fun <reified T> inject(): Lazy<T>{
    val context = GlobalContext.get().koin
    return remember(context) { context.inject() }
}
So, I'd call 😀
Copy code
val repository: Repository by inject()
Instead of
Copy code
val repository: Repository = inject()
s
Makes sense and matches the local delegate usage pattern of state / mutableStateOf in compose.
Is the context guaranteed to never change?
If so, this would be slightly more performant:
Copy code
/ ...
return remember {
    val context = ...
    context.inject()
}
✔️ 1
h
Good one. GlobalContext is an
object
so I suppose it won't change
a
Yes, Default Koin context won’t change, no problem 👍
could be interesting to have a
koin-androidx-compose
sub project then, gathering the needed extensions
🤘 1
h
Really cool. I can prepare a PR 🙂
💯 1