How to expose methods in custom extensions?

Hi! I wrote a simple custom extension MyExtension (imagine any of the examples provided in the docs). The typescript view of my extension has a method that I would like to be able to trigger under certain conditions (e.g. a user clicks a button widget). I tried doing something like button.js_on_click(args={'my_extension' :my_extension}, code="""my_extension.myMethod()""". The problem is that this won’t work because myMethod is not exported from the MyExtensionView , and I don’t know how I’d expose it.

I suspect I need to change something in the export section of the typescript file. Somewhere here

  export type Attrs = p.AttrsOf<Props>

  export type Props = InputWidget.Props & {
    range: p.Property<[number, number]>
    start: p.Property<number>
    end: p.Property<number>
    step: p.Property<number>
    grid: p.Property<boolean>
  }
//Export myMethod somehow here?
}

A possible workaround could be to create a property in MyExtension, and make the button change its value. By using connect_signals changes in that property could cause myMethod to trigger.

Is there some example or somewhere in the code I could use as reference to achieve this?