【修改】@ohos.arkui.StateManagement.d.ts文档内容

Signed-off-by: wangyanchao <wangyanchao16@huawei.com>
This commit is contained in:
wangyanchao 2024-06-21 08:30:24 +08:00
parent 5c1d2ab390
commit 6cedaf4081

View File

@ -12,12 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file State management API file
* @kit ArkUI
*/
/**
* Function that returns default creator.
*
@ -30,6 +30,26 @@
*/
export declare type StorageDefaultCreator<T> = () => T;
/**
* Define class constructor with arbitrary parameters.
* @interface TypeConstructorWithArgs<T>
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
export interface TypeConstructorWithArgs<T> {
/**
* @param { any } args the arguments of the constructor.
* @returns { T } return class instance.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
new(...args: any): T;
}
/**
* AppStorageV2 is for UI state of app-wide access, has same life cycle as the app,
* and saves database content only in memory.
@ -44,7 +64,8 @@ export declare class AppStorageV2 {
* If the value for the given key is already available, return the value.
* If not, add the key with value generated by calling defaultFunc and return it to caller.
*
* @param { string } key key adding
* @param { TypeConstructorWithArgs<T> } type class type of the stored value.
* @param { string | StorageDefaultCreator<T> } [keyOrDefaultCreator] alias name of the key, or the function generating the default value.
* @param { StorageDefaultCreator<T> } [defaultCreator] the function generating the default value
* @returns { T | undefined } the value of the existed key or the default value
* @syscap SystemCapability.ArkUI.ArkUI.Full
@ -52,19 +73,22 @@ export declare class AppStorageV2 {
* @atomicservice
* @since 12
*/
static connect<T extends object>(key: string, defaultCreator?: StorageDefaultCreator<T>): T | undefined;
static connect<T extends object>(
type: TypeConstructorWithArgs<T>,
keyOrDefaultCreator?: string | StorageDefaultCreator<T>,
defaultCreator?: StorageDefaultCreator<T>
): T | undefined;
/**
* Removes the given key. Return false if the given key does not exist.
* Removes data with the given key or given class type.
*
* @param { string } key key removing
* @returns { boolean } exist or not
* @param { string | TypeConstructorWithArgs<T> } keyOrType key or class type removing
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
static remove(key: string): boolean;
static remove<T>(keyOrType: string | TypeConstructorWithArgs<T>): void;
/**
* Return the array of all keys.
@ -75,9 +99,9 @@ export declare class AppStorageV2 {
* @atomicservice
* @since 12
*/
static keys() : Array<string>;
static keys(): Array<string>;
}
/**
* Function that returns reason type when error.
*
@ -91,7 +115,7 @@ export declare class AppStorageV2 {
* @since 12
*/
export declare type PersistenceErrorCallback = (key: string, reason: 'quota' | 'serialization' | 'unknown', message: string) => void;
/**
* PersistenceV2 is for UI state of app-wide access, available on app re-start,
* and saves database content in disk.
@ -104,15 +128,15 @@ export declare type PersistenceErrorCallback = (key: string, reason: 'quota' | '
*/
export declare class PersistenceV2 extends AppStorageV2 {
/**
* The purpose of the save function is request to persist non-observed object changes.
* Used to manually persist data changes to disks.
*
* @param { string } key key need to save, that persist non-observed object changes
* @param { string | TypeConstructorWithArgs<T> } keyOrType key or class type need to persist.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
static save(key: string): void;
static save<T>(keyOrType: string | TypeConstructorWithArgs<T>): void;
/**
* Be called when persisting has encountered an error.
@ -125,7 +149,7 @@ export declare class PersistenceV2 extends AppStorageV2 {
*/
static notifyOnError(callback: PersistenceErrorCallback | undefined): void;
}
/**
* Define TypeConstructor type.
*
@ -145,7 +169,7 @@ export interface TypeConstructor<T> {
*/
new(): T;
}
/**
* Function that returns PropertyDecorator.
*
@ -158,7 +182,7 @@ export interface TypeConstructor<T> {
* @since 12
*/
export declare type TypeDecorator = <T>(type: TypeConstructor<T>) => PropertyDecorator;
/**
* Define Type PropertyDecorator, adds type information to an object.
*