github manzt/anywidget @anywidget/types@0.1.7

latest releases: create-anywidget@0.7.5, create-anywidget@0.7.3, create-anywidget@0.7.2...
7 months ago

Patch Changes

  • Add experimental invoke API to call Python functions from the front end and (#453)
    await the response.

    This removes a lot of boilerplate required for this pattern. The API is
    experimental and opt-in only. Subclasses must use the command to register
    functions.

    class Widget(anywidget.AnyWidget):
        _esm = """
        export default {
          async render({ model, el, experimental }) {
            let [msg, buffers] = await experimental.invoke("_echo", "hello, world");
            console.log(msg); // "HELLO, WORLD"
          },
        };
        """
    
        @anywidget.experimental.command
        def _echo(self, msg, buffers):
            # upper case the message
            return msg.upper(), buffers

Don't miss a new anywidget release

NewReleases is sending notifications on new releases.