Has anyone used Kotlin context receivers in an And...
# android
b
Has anyone used Kotlin context receivers in an Android project? What are the exact use cases you have solved in real Android problems?
s
I've used them sparingly, mainly to cut-down on boilerplate. I have a fragment where there are about a twenty different state-flows to observe and update some traditional Android views, and this was a massive function in the fragment, so i extracted the function to a different file with the viewmodel and fragment as receivers
b
Thanks, Steven! Do you have any example code snippets that could help me better understand?
c
I would not use context receivers now - there will be a different concept, context parameters You can find a talk about it from KotlinConf over here https://kotlinconf.com/talks/621119/
b
So if I understood correctly they dropped context receivers right ?
👌 1