preactjs / preact-custom-element

Wrap your component up as a custom element
MIT License
360 stars 52 forks source link

Expose methods #70

Closed bestwestern closed 2 years ago

bestwestern commented 2 years ago

Is this possible to do image

That is, call the method of a Preact Component from 'outside'? ( https://stackoverflow.com/questions/39439085/custom-methods-of-web-components )

Use case: I am making a web component to display data and want to expose a 'dataWasUpdated' method that can be called.

bestwestern commented 2 years ago

I am closing this issue - I don't think Web Components are 'supposed' to be able to do this :)

wolfwithdances commented 2 years ago

I think this is supposedly possible, as on web.dev:

The powerful thing about custom elements is that you can bundle tailored functionality with the element by defining properties and methods on the element definition. Think of this as a way to create a public API for your element.

Per #1, it does not seem like this is possible right now.