Skip to content

Binding clarification/improvements #336

@mitchcapper

Description

@mitchcapper

Thanks for such a smart concept of a project. I recently did a pr to update the nice C# implementation that @Juff-Ma put together to conform to more standardized c# constructs. I put together a more complex sample showing some of the features here.

The bind functionality is a bit interesting. With the same function being called to either attach to a click handler or to register a backer library bound JS function is is a bit unclear what the expected behavior is. I believe the wrapper interface (webui_interface_*) is to make it a bit easier than the non-interface ones. Still it sounds like webui_bind when called with the ID of something not in the DOM registers the function to webui.call("FuncName") and aliases of webui.FuncName and window.FuncName. Calling the interface version does not though, there we only see bound functions from webui.call("*"). Now it isn't hard to write similar wrappers although as this is likely functionality most libraries would want it might be better to implement that at a native library level. I did try with the nightly from a few weeks ago but seemed to get the same result.

While webui is almost by very nature async given it uses web sockets, the basic ABI binding is clearly not. It does almost require callback interop though so it isn't as if supporting some level of async wouldn't be possible. I think the place that may have the biggest benefit would be for bound call responses. There are already separate methods for setting the response, but right now they trigger as soon as the main event returns. Not a big deal but it would be nice if there was a deferral style option.

There are a few other things that would be nice too, another bound one is arg length. Without writing a proxy JS side for calls I don't see a way of determining how many args we actually get called with.

I think given the target as a UI frontend the other major one is just expanding from click events to any eventListener event. Again library authors can work around these things very easily with javascript and language based wrappers, but it is great how many languages WebUI supports and keeping implementation requirements by libs to a minimum probably helps keep it higher.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions