From 4fce12340774cfb076d06bc194efc32d3d28e878 Mon Sep 17 00:00:00 2001 From: chenbenzhi Date: Wed, 18 Jun 2025 22:10:04 +0800 Subject: [PATCH] add decorator.d.ets Signed-off-by: chenbenzhi --- api/arkui/stateManagement/decorator.d.ets | 778 ++++++++++++++++++++-- 1 file changed, 720 insertions(+), 58 deletions(-) diff --git a/api/arkui/stateManagement/decorator.d.ets b/api/arkui/stateManagement/decorator.d.ets index a626dc9e89..4ecd2da559 100644 --- a/api/arkui/stateManagement/decorator.d.ets +++ b/api/arkui/stateManagement/decorator.d.ets @@ -77,121 +77,783 @@ export declare @interface Watch { @Retention({policy: "SOURCE"}) export declare @interface Require {}; + +/** + * Define decorated variable interface. + * + * @interface IDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IDecoratedVariable { - readonly varName: string; + /** + * Decorated variable name. + * + * @type { string } + * @readonly + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + readonly varName: string; } +/** + * Define V1 decorated variable interface. + * + * @extends IDecoratedVariable + * @interface IDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IDecoratedV1Variable extends IDecoratedVariable { - registerWatchToSource(me: IDecoratedV1Variable): void; + /** + * Registers the watch callback function with the data source. + * + * @param { IDecoratedV1Variable } decoratedVar + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + registerWatchToSource(decoratedVar: IDecoratedV1Variable): void; } +/** + * Define decorated immutable variable interface. + * + * @interface IDecoratedImmutableVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IDecoratedImmutableVariable { - get(): T; + /** + * Get the state variable. + * + * @returns { T } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + get(): T; } +/** + * Define decorated mutable variable interface. + * + * @interface IDecoratedMutableVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IDecoratedMutableVariable { - get(): T; - set(newValue: T): void; + /** + * Get the state variable. + * + * @returns { T } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + get(): T; + /** + * Set the state variable with a new Value. + * + * @param { T } newValue + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + set(newValue: T): void; } +/** + * Define decorated updatable variable interface. + * + * @interface IDecoratedUpdatableVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IDecoratedUpdatableVariable { - update(newValue: T): void; + /** + * Update the state variable with a new Value. + * + * @param { T } newValue + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + update(newValue: T): void; } -export declare interface IStateDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable { -} +/** + * Define state decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV1Variable + * @interface IStateDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IStateDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable {} -export declare interface IPropDecoratedVariable extends IDecoratedMutableVariable, - IDecoratedUpdatableVariable, IDecoratedV1Variable { -} +/** + * Define PropRef decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedUpdatableVariable, IDecoratedV1Variable + * @interface IPropRefDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IPropRefDecoratedVariable extends IDecoratedMutableVariable, + IDecoratedUpdatableVariable, IDecoratedV1Variable {} -export declare interface ILinkDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable { -} +/** + * Define Link decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV1Variable + * @interface ILinkDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface ILinkDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable {} -export declare interface IProvideDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable { -} +/** + * Define Provide decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV1Variable + * @interface IProvideDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IProvideDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable {} -export declare interface IConsumeDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable { -} +/** + * Define Consume decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV1Variable + * @interface IConsumeDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IConsumeDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable {} +/** + * Define ObjectLink decoration variable interface. + * + * @extends IDecoratedImmutableVariable, IDecoratedUpdatableVariable, IDecoratedV1Variable + * @interface IObjectLinkDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IObjectLinkDecoratedVariable extends IDecoratedImmutableVariable, - IDecoratedUpdatableVariable, IDecoratedV1Variable { -} + IDecoratedUpdatableVariable, IDecoratedV1Variable {} -export declare interface IStorageLinkDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable { -} +/** + * Define StorageLink decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV1Variable + * @interface IStorageLinkDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IStorageLinkDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable {} -export declare interface IStoragePropDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable { -} +/** + * Define StoragePropRef decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV1Variable + * @interface IStoragePropRefDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IStoragePropRefDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable {} -export type LinkSourceType = IDecoratedV1Variable; +/** + * Define LocalStoragePropRef decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV1Variable + * @interface ILocalStoragePropRefDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface ILocalStoragePropRefDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable {} + +/** + * Define LocalStorageLink decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV1Variable + * @interface ILocalStorageLinkDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface ILocalStorageLinkDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable {} + +/** + * Define Link source type. + * + * @typedef { IDecoratedV1Variable } LinkSourceType + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export type LinkSourceType = IStateDecoratedVariable | ILinkDecoratedVariable | IObjectLinkDecoratedVariable | + IPropRefDecoratedVariable | IStorageLinkDecoratedVariable | ILocalStorageLinkDecoratedVariable + IStoragePropRefDecoratedVariable | ILocalStoragePropRefDecoratedVariable | + IProvideDecoratedVariable | IConsumeDecoratedVariable; + +/** + * Define Local decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV2Variable + * @interface ILocalDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface ILocalDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV2Variable {} +/** + * Define mutable state meta interface. + * + * @interface IMutableStateMeta + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IMutableStateMeta { - addRef(): void; - fireChange(): void; + /** + * Collect the dependancy for UI component with state variable + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + addRef(): void; + /** + * Notify UI component to update when state variable is changed + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + fireChange(): void; } +/** + * Define V2 decorated variable interface. + * + * @extends IDecoratedVariable + * @interface IDecoratedV2Variable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export interface IDecoratedV2Variable extends IDecoratedVariable {} + +/** + * Define mutable state meta interface with key. + * + * @interface IMutableKeyedStateMeta + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IMutableKeyedStateMeta { - addRef(key: string): void; - addRef(index: int): void; - fireChange(key: string): void; - fireChange(index: int): void; + /** + * Collect the dependancy for UI component with state variable based on given key + * + * @param { string } key + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + addRef(key: string): void; + /** + * Collect the dependancy for UI component with state variable based on given key + * + * @param { int } index + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + addRef(index: int): void; + /** + * Notify UI component with given key to update when state variable is changed + * + * @param { string } key + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + fireChange(key: string): void; + /** + * Notify UI component with given key to update when state variable is changed + * + * @param { int } index + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + fireChange(index: int): void; } +/** + * Define Param decoration variable interface. + * + * @extends IDecoratedImmutableVariable, IDecoratedUpdatableVariable, IDecoratedV2Variable + * @interface IParamV2DecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IParamV2DecoratedVariable extends IDecoratedImmutableVariable, IDecoratedUpdatableVariable, IDecoratedV2Variable {} + +/** + * Define IObserve interface. + * + * @interface IObserve + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IObserve { - readonly renderingComponent: number; - readonly renderingId: RenderIdType; - shouldAddRef(iObjectsRenderId: RenderIdType): boolean; + /** + * Rendering component. + * + * @type { number } + * @readonly + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + readonly renderingComponent: number; + /** + * Rendering component id. + * + * @type { RenderIdType } + * @readonly + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + readonly renderingId: RenderIdType; + /** + * Collect the dependancy for UI component with state variable + * + * @param { RenderIdType } iObjectsRenderId + * @returns { boolean } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + shouldAddRef(iObjectsRenderId: RenderIdType): boolean; } +/** + * Define Param Once decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV2Variable + * @interface IParamOnceV2DecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IParamOnceV2DecoratedVariable extends IDecoratedMutableVariable, IDecoratedV2Variable {} + +/** + * Define OBSERVED. + * + * @type { IObserve } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare const OBSERVE: IObserve; +/** + * Define Provider decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV2Variable + * @interface IProviderDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IProviderDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV2Variable {} + +/** + * Define int alias. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export type RenderIdType = int; +/** + * Define Consumer decoration variable interface. + * + * @extends IDecoratedMutableVariable, IDecoratedV2Variable + * @interface IConsumerDecoratedVariable + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare interface IConsumerDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV2Variable {} + +/** + * Define IObservedObject interface. + * + * @extends IWatchSubscriberRegister + * @interface IObservedObject + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IObservedObject extends IWatchSubscriberRegister { - setV1RenderId(renderId: RenderIdType): void; + /** + * Set V1 renderId + * + * @param { RenderIdType } renderId + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + setV1RenderId(renderId: RenderIdType): void; } +/** + * Define STATE_MGMT_FACTORY. + * + * @type { IStateMgmtFactory } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare const STATE_MGMT_FACTORY: IStateMgmtFactory; +/** + * Define IStateMgmtFactory interface. + * + * @interface IStateMgmtFactory + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IStateMgmtFactory { - makeMutableStateMeta(): IMutableStateMeta; - makeSubscribedWatches(): ISubscribedWatches; - makeState(owningView: ExtendableComponent, varName: string, initValue: T, - watchFunc?: WatchFuncType): IStateDecoratedVariable; - makeProp(owningView: ExtendableComponent, varName: string, initValue: T, - watchFunc?: WatchFuncType): IPropDecoratedVariable; - makeLink(owningView: ExtendableComponent, varName: string, source: LinkSourceType, - watchFunc?: WatchFuncType): ILinkDecoratedVariable; - makeProvide(owningView: ExtendableComponent, varName: string, provideAlias: string, - initValue: T, allowOverride: boolean, wathcFunc?: WatchFuncType): IProvideDecoratedVariable; - makeConsume(owningView: ExtendableComponent, varName: string, - provideAlias: string, watchFunc?: WatchFuncType): IConsumeDecoratedVariable; - makeObjectLink(owningView: ExtendableComponent, varName: string, - initValue: T, wathcFunc?: WatchFuncType): IObjectLinkDecoratedVariable; - makeStorageLink(owningView: ExtendableComponent, propName: string, - varName: string, initValue: T, watchFunc?: WatchFuncType): IStorageLinkDecoratedVariable; - makeStorageProp(owningView: ExtendableComponent, propName: string, - varName: string, initValue: T, watchFunc?: WatchFuncType): IStoragePropDecoratedVariable; + /** + * get mutable state meta + * + * @returns { IMutableStateMeta } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeMutableStateMeta(): IMutableStateMeta; + /** + * get subscribed watches + * + * @returns { ISubscribedWatches } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeSubscribedWatches(): ISubscribedWatches; + /** + * Create a State variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { T } initValue - state variable initValue. + * @param { WatchFuncType } [watchFunc] - watch type + * @returns { IStateDecoratedVariable } State instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeState(owningView: ExtendableComponent, varName: string, initValue: T, + watchFunc?: WatchFuncType): IStateDecoratedVariable; + /** + * Create a PropRef variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { T } initValue - state variable initValue. + * @param { WatchFuncType } [watchFunc] - watch type + * @returns { IPropRefDecoratedVariable } PropRef instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makePropRef(owningView: ExtendableComponent, varName: string, initValue: T, + watchFunc?: WatchFuncType): IPropRefDecoratedVariable; + + /** + * Create a Link variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { LinkSourceType } source - state variable sync source. + * @param { WatchFuncType } [watchFunc] - watch type + * @returns { ILinkDecoratedVariable } PropRef instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeLink(owningView: ExtendableComponent, varName: string, source: LinkSourceType, + watchFunc?: WatchFuncType): ILinkDecoratedVariable; + + /** + * Create a Provide variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { string } provideAlias - provide alias. + * @param { T } initValue - init value. + * @param { Type } ttype - value type. + * @param { boolean } allowOverride - Override the @Provide of any parent or parent of parent @Component.@Provide({allowOverride: "name"}) is + * also allowed to be used even when there is no ancestor @Component whose @Provide would be overridden. + * @param { WatchFuncType } [wathcFunc] - watch type + * @returns { IProvideDecoratedVariable } Provide instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeProvide(owningView: ExtendableComponent, varName: string, provideAlias: string, + initValue: T, allowOverride: boolean, ttype: Type, wathcFunc?: WatchFuncType): IProvideDecoratedVariable; + + /** + * Create a Consume variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { string } provideAlias - provide alias. + * @param { Type } ttype - value type. + * @param { WatchFuncType } [watchFunc] - watch type + * @returns { IConsumeDecoratedVariable } Consume instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeConsume(owningView: ExtendableComponent, varName: string, + provideAlias: string, ttype: Type, watchFunc?: WatchFuncType): IConsumeDecoratedVariable; + + /** + * Create a ObjectLink variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { T } initValue - init value. + * @param { WatchFuncType } [wathcFunc] - watch type + * @returns { IObjectLinkDecoratedVariable } ObjectLink instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeObjectLink(owningView: ExtendableComponent, varName: string, + initValue: T, wathcFunc?: WatchFuncType): IObjectLinkDecoratedVariable; + + /** + * Create a StorageLink variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } propName - property name. + * @param { string } varName - state variable name. + * @param { T } initValue - init value. + * @param { Type } ttype - value type. + * @param { WatchFuncType } [watchFunc] - watch type + * @returns { IStorageLinkDecoratedVariable } StorageLink instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeStorageLink(owningView: ExtendableComponent, propName: string, + varName: string, initValue: T, ttype: Type, watchFunc?: WatchFuncType): IStorageLinkDecoratedVariable; + + /** + * Create a StoragePropRef variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } propName - property name. + * @param { string } varName - state variable name. + * @param { T } initValue - init value. + * @param { Type } ttype - value type. + * @param { WatchFuncType } [watchFunc] - watch type + * @returns { IStoragePropRefDecoratedVariable } StoragePropRef instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeStoragePropRef(owningView: ExtendableComponent, propName: string, + varName: string, initValue: T, ttype: Type, watchFunc?: WatchFuncType): IStoragePropRefDecoratedVariable; + + /** + * Create a LocalStoragePropRef variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } propName - property name. + * @param { string } varName - state variable name. + * @param { T } initValue - init value. + * @param { Type } ttype - value type. + * @param { WatchFuncType } [watchFunc] - watch type + * @returns { ILocalStoragePropRefDecoratedVariable } StoragePropRef instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeLocalStoragePropRef(owningView: ExtendableComponent, propName: string, + varName: string, initValue: T, ttype: Type, watchFunc?: WatchFuncType): ILocalStoragePropRefDecoratedVariable; + + /** + * Create a LocalStorageLink variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } propName - property name. + * @param { string } varName - state variable name. + * @param { T } initValue - init value. + * @param { Type } ttype - value type + * @param { WatchFuncType } [watchFunc] - watch type + * @returns { IStoragePropRefDecoratedVariable } StoragePropRef instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeLocalStorageLink(owningView: ExtendableComponent, propName: string, + varName: string, initValue: T, ttype: Type, watchFunc?: WatchFuncType): IStoragePropRefDecoratedVariable; + + /** + * Create a Local variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { T } localInitValue - state variable initValue. + * @returns { ILocalDecoratedVariable } Local instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeLocal(owningView: ExtendableComponent, varName: string, localInitValue: T): ILocalDecoratedVariable; + + /** + * Create a Param variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { T } initValue - param variable initValue. + * @returns { IParamDecoratedVariable } Param instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeParam(owningView: ExtendableComponent, varName: string, initValue: T): IParamDecoratedVariable; + + /** + * Create a param once variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - state variable name. + * @param { T } initValue - param once variable initValue. + * @returns { IParamOnceV2DecoratedVariable } Param Once instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeParamOnce(owningView: ExtendableComponent, varName: string, initValue: T): IParamOnceV2DecoratedVariable; + + /** + * Create a provider variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - provider variable name. + * @param { string } providerAlias - provider alias. + * @param { T } localInitValue - provider local variable value. + * @param { Type } ttype - value type. + * @returns { IProviderDecoratedVariable } Provider instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeProvider(owningView: ExtendableComponent, varName: string, providerAlias: string, localInitValue: T, ttype: Type): IProviderDecoratedVariable; + + /** + * Create a consumer variable instance. + * + * @param { ExtendableComponent } owningView - custom component. + * @param { string } varName - consumer variable name. + * @param { string } providerAlias - consumer alias. + * @param { T } defaultValue - consumer default value. + * @param { Type } ttype - value type. + * @returns { IConsumerDecoratedVariable } Consumer instance + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + makeConsumer(owningView: ExtendableComponent, varName: string, providerAlias: string, defaultValue: T, ttype: Type): IConsumerDecoratedVariable; } -export type WatchFuncType = ((propertyName: string) => void); +/** + * Defines the callback that is called when state variable is change + * @typedef { function } WatchFuncType + * @param {string} propertyName - property name + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export type WatchFuncType = (propertyName: string) => void; +/** + * Define int alias. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export type WatchIdType = int; +/** + * Define IWatchSubscriberRegister interface. + * + * @interface IWatchSubscriberRegister + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface IWatchSubscriberRegister { - addWatchSubscriber(watchId: WatchIdType): void; - removeWatchSubscriber(watchId: WatchIdType): boolean; + /** + * Registers the watch function callback. + * + * @param { WatchIdType } watchId - the watch function id + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + addWatchSubscriber(watchId: WatchIdType): void; + /** + * UnRegister the watch function callback. + * + * @param { WatchIdType } watchId - the watch function id + * @returns { boolean } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + removeWatchSubscriber(watchId: WatchIdType): boolean; } +/** + * Define ISubscribedWatches interface. + * + * @extends IWatchSubscriberRegister + * @interface ISubscribedWatches + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface ISubscribedWatches extends IWatchSubscriberRegister { - executeOnSubscribingWatches(propertyName: string): void; + /** + * Execute the watch function callback. + * + * @param { string } propertyName - property name + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + executeOnSubscribingWatches(propertyName: string): void; } +/** + * Define AbstractProperty interface. + * + * AbstractProperty can be understood as a handler or an alias + * to a property inside LocalStorage / AppStorage singleton + * allows to read the value with @see get and to change the + * value with @see set. + * + * @extends IDecoratedMutableVariable + * @interface AbstractProperty + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface AbstractProperty extends IDecoratedMutableVariable { - info(): string; + /** + * returns the name of the referenced property + * + * @returns { string } name of the referenced property + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + info(): string; } +/** + * SubscribedAbstractProperty is the return value of + * - AppStorage static functions Link(), Prop(), SetAndLink(), and SetAndProp() + * - LocalStorage member methods link(), prop(), setAndLink(), and setAndProp() + * 'T' can be boolean, string, number or custom class. + * Main functions + * see get() reads the linked AppStorage/LocalStorage property value, + * see set(newValue) write a new value to the synched AppStorage/LocalStorage property + * see aboutToBeDeleted() ends the sync relationship with the AppStorage/LocalStorage property + * The app must call this function before the SubscribedAbstractProperty object + * goes out of scope. + * + * @extends AbstractProperty + * @interface SubscribedAbstractProperty + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ export declare interface SubscribedAbstractProperty extends AbstractProperty { - aboutToBeDeleted(): void; + /** + * An app needs to call this function before the instance of SubscribedAbstractProperty + * goes out of scope / is subject to garbage collection. Its purpose is to unregister the + * variable from the two-way/one-way sync relationship that AppStorage/LocalStorage.link()/prop() + * and related functions create. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + aboutToBeDeleted(): void; } \ No newline at end of file -- Gitee