Bryan Lee
12/17/2019, 7:33 PMprivate fun WebView.setRef(ref: (WebView) -> Unit) {
ref(this)
}
Taken from ui/ui-android-view/src/main/java/androidx/ui/androidview/WebComponent.ktLuca Nicoletti
12/17/2019, 7:40 PMref
function it accept as a parameter providing this
as receiver of that function 🤔Bryan Lee
12/17/2019, 7:48 PMZach Klippenstein (he/him) [MOD]
12/17/2019, 8:38 PMView
in a composable, you invoke it as a function – you don’t instantiate it, so you never actually have a reference to the View
object. This pattern gets you around that.Leland Richardson [G]
12/17/2019, 8:54 PMWebView.setRef
function above gets interpreted as a ref
parameter in the composable webview call.
It’s a bit weird, which is why we haven’t talked a ton about it yet, and some of it still might changeBryan Lee
12/17/2019, 10:07 PMZach Klippenstein (he/him) [MOD]
12/18/2019, 6:02 PM