SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.52k stars 264 forks source link

[Feature Request]: Properties of type function #9989

Open swendlandt opened 1 week ago

swendlandt commented 1 week ago

Feature Request Description

ui5-webcomponents define different types of properties: https://sap.github.io/ui5-webcomponents/docs/development/properties/#type

"function" is not one of them, but it could be helpful to pass callbacks to a custom web component. I am aware that in general custom events are preferable over callbacks for web components, but there are still use cases where callbacks make sense in my opinion, e.g. an asynchronous callback to fetch data.

Proposed Solution

Provide a new type of property "function"

Proposed Alternatives

No response

Organization

SAP

Additional Context

No response

Priority

Medium

Privacy Policy

NHristov-sap commented 6 days ago

Hello @SAP/ui5-webcomponents-topic-core , take a look of this feature request.

Best Regards, Nikolay Hristov

pskelin commented 1 day ago

@swendlandt you don't strictly need a type other than Boolean and Number - they are used for converting from property to an attribute and vice versa. The remaining types are String which is 1:1 mapping with the attribute and the rest effectively set { noAttribute: true }

For your usage, you can directly write

    @property({ noAttribute: true })
    callback?: () => void;

and then document what is the expected value of the property.