openharmony 鸿蒙 ts-universal-wrapBuilder

2026-08-25 浏览 (1)

wrapBuilder

The wrapBuilder function encapsulates global @Builder functions to improve code maintainability. For details, see wrapBuilder: Encapsulating Global @Builder.

NOTE

The initial APIs of this module are supported since API version 11.

Newly added APIs will be marked with a superscript to indicate their earliest API version.

wrapBuilder

wrapBuilder<Args extends Object[]>(builder: (...args: Args) => void): WrappedBuilder<Args>

A template function that returns a WrappedBuilder object. The template parameter Args extends Object[] represents the parameter list of the builder function to be encapsulated.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
builder(...args: Args) => voidYesGlobal function decorated with @Builder.

Return value

TypeDescription
WrappedBuilder<Args>WrappedBuilder object.

Example

@Builder
function MyBuilder(value: string, size: number) {
  Text(value)
    .fontSize(size)
}
let builderVar: WrappedBuilder<[string, number]> = wrapBuilder(MyBuilder);

WrappedBuilder

Implements the encapsulation class for @Builder functions. The template parameter Args extends Object[] must match the parameter type list of the @Builder function.

Properties

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeRead-OnlyOptionalDescription
builder(...args: Args) => voidNoNoGlobal function decorated with @Builder.

constructor

constructor(builder: (...args: Args) => void)

A constructor used to create a WrappedBuilder instance.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
builder(...args: Args) => voidYesGlobal function decorated with @Builder.

Example

@Builder
function MyBuilder(value: string, size: number) {
  Text(value)
    .fontSize(size)
}
let builderVar: WrappedBuilder<[string, number]> = new WrappedBuilder<[string, number]>(MyBuilder);

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 ts-drawing-components-shape

openharmony 鸿蒙 ts-universal-attributes-sharp-clipping

openharmony 鸿蒙 ts-universal-attributes-toolbar

openharmony 鸿蒙 ts-container-lazyvgridlayout

openharmony 鸿蒙 ohos-arkui-advanced-FoldSplitContainer

openharmony 鸿蒙 ts-methods-calendarpicker-dialog

openharmony 鸿蒙 ts-uicommonevent

openharmony 鸿蒙 ts-basic-gestures-tapgesture

openharmony 鸿蒙 ohos-arkui-advanced-DialogV2

openharmony 鸿蒙 ts-components-canvas-canvas

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/PRJmcPDo