by mcintyre1994 · 5y ago · 0 comments
I guess that's the magic behind most JS data binding libraries?
I do find the syntax on the Gleam side a little bit odd:
external fn query_selector(String) -> Element =
"" "document.querySelector"
Becomes: function query_selector(arg0) {
return document.querySelector(arg0)
}
I'm not sure what the empty string first argument is doing in this case.Most of the functions on Reflect can be done using built-in language features, I haven’t seen much use of it in libraries.
For reactive, magic data binding see Proxy, which allows a callback on object property access for arbitrary objects. Proxy is the magic behind Mobx for instance. Reflect fits in well because it can be used as the “default” or fallback implementation for Proxy methods. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...