1/* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkUI 19 */ 20 21/** 22 * AppStorage singleton is sub-class of see LocalStorage for 23 * UI state of app-wide access and same life cycle as the app. 24 * 25 * @syscap SystemCapability.ArkUI.ArkUI.Full 26 * @since 7 27 */ 28/** 29 * AppStorage singleton is sub-class of see LocalStorage for 30 * UI state of app-wide access and same life cycle as the app. 31 * 32 * @syscap SystemCapability.ArkUI.ArkUI.Full 33 * @crossplatform 34 * @since 10 35 */ 36/** 37 * AppStorage singleton is sub-class of see LocalStorage for 38 * UI state of app-wide access and same life cycle as the app. 39 * 40 * @syscap SystemCapability.ArkUI.ArkUI.Full 41 * @crossplatform 42 * @atomicservice 43 * @since 11 44 */ 45declare class AppStorage { 46 /** 47 * Obtain a handler or an alias to AppStorage property with given name. 48 * 49 * @param { string } propName AppStorage property name 50 * @returns { AbstractProperty<T> | undefined } AbstractProperty object if property with given name exists 51 * return undefined otherwise 52 * @syscap SystemCapability.ArkUI.ArkUI.Full 53 * @crossplatform 54 * @atomicservice 55 * @since 12 56 */ 57 static ref<T>(propName: string): AbstractProperty<T> | undefined; 58 59 /** 60 * Obtain a handler or an alias to AppStorage property with given name. 61 * 62 * If property does not exist in AppStorage, create it with given default value. 63 * 64 * @param { string } propName AppStorage property name 65 * @param { T } defaultValue If property does not exist in AppStorage, 66 * create it with given default value. 67 * @returns { AbstractProperty<T> } AbstractProperty object 68 * @syscap SystemCapability.ArkUI.ArkUI.Full 69 * @crossplatform 70 * @atomicservice 71 * @since 12 72 */ 73 static setAndRef<T>(propName: string, defaultValue: T): AbstractProperty<T>; 74 75 /** 76 * Called when a link is set. 77 * Create and return a two-way sync ("link") to named property 78 * 79 * @param { string } propName 80 * @returns { any } 81 * @syscap SystemCapability.ArkUI.ArkUI.Full 82 * @since 7 83 * @deprecated since 10 84 * @useinstead AppStorage#link 85 */ 86 static Link(propName: string): any; 87 88 /** 89 * Create and return a two-way sync ("link") to named property 90 * Same as @see LocalStorage.link() 91 * 92 * @param { string } propName - name of source property in AppStorage 93 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 94 * return 'undefined' if named property does not already exist in AppStorage 95 * @syscap SystemCapability.ArkUI.ArkUI.Full 96 * @crossplatform 97 * @since 10 98 */ 99 /** 100 * Create and return a two-way sync ("link") to named property 101 * Same as @see LocalStorage.link() 102 * 103 * @param { string } propName - name of source property in AppStorage 104 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 105 * return 'undefined' if named property does not already exist in AppStorage 106 * @syscap SystemCapability.ArkUI.ArkUI.Full 107 * @crossplatform 108 * @atomicservice 109 * @since 11 110 */ 111 static link<T>(propName: string): SubscribedAbstractProperty<T>; 112 113 /** 114 * Like see @Link(), but will create and initialize a new source property in AppStorage if missing 115 * Same as see LocalStorage.setAndLink() 116 * 117 * @param { string } propName 118 * @param { T } defaultValue 119 * @returns { SubscribedAbstractProperty<T> } 120 * @syscap SystemCapability.ArkUI.ArkUI.Full 121 * @since 7 122 * @deprecated since 10 123 * @useinstead AppStorage#setAndLink 124 * @see setAndLink 125 */ 126 static SetAndLink<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 127 128 /** 129 * Like see @link(), but will create and initialize a new source property in AppStorage if missing 130 * Same as see LocalStorage.setAndLink() 131 * 132 * @param { string } propName - name of source property in AppStorage 133 * @param { T } defaultValue - value to be used for initializing if new creating new property in AppStorage 134 * default value must be of type T, must not be 'undefined' or 'null'. 135 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 136 * @syscap SystemCapability.ArkUI.ArkUI.Full 137 * @crossplatform 138 * @since 10 139 */ 140 /** 141 * Like see @link(), but will create and initialize a new source property in AppStorage if missing 142 * Same as see LocalStorage.setAndLink() 143 * 144 * @param { string } propName - name of source property in AppStorage 145 * @param { T } defaultValue - value to be used for initializing if new creating new property in AppStorage 146 * default value must be of type T, must not be 'undefined' or 'null'. 147 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 148 * @syscap SystemCapability.ArkUI.ArkUI.Full 149 * @crossplatform 150 * @atomicservice 151 * @since 11 152 */ 153 /** 154 * Like see @link(), but will create and initialize a new source property in AppStorage if missing 155 * Same as see LocalStorage.setAndLink() 156 * 157 * @param { string } propName - name of source property in AppStorage 158 * @param { T } defaultValue - value to be used for initializing new property in AppStorage 159 * default value must be of type T, can be undefined or null. 160 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 161 * @syscap SystemCapability.ArkUI.ArkUI.Full 162 * @crossplatform 163 * @atomicservice 164 * @since 12 165 */ 166 static setAndLink<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 167 168 /** 169 * Called when a property is set. 170 * Create and return a one-way sync ('prop') to named property 171 * 172 * @param { string } propName 173 * @returns { any } 174 * @syscap SystemCapability.ArkUI.ArkUI.Full 175 * @since 7 176 * @deprecated since 10 177 * @useinstead AppStorage#prop 178 */ 179 static Prop(propName: string): any; 180 181 /** 182 * Create and return a one-way sync ('prop') to named property 183 * Same as @see LocalStorage.prop() 184 * 185 * @param { string } propName - name of source property in AppStorage 186 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 187 * return undefined if named property does not already exist in AppStorage. 188 * @syscap SystemCapability.ArkUI.ArkUI.Full 189 * @crossplatform 190 * @since 10 191 */ 192 /** 193 * Create and return a one-way sync ('prop') to named property 194 * Same as @see LocalStorage.prop() 195 * 196 * @param { string } propName - name of source property in AppStorage 197 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 198 * return undefined if named property does not already exist in AppStorage. 199 * @syscap SystemCapability.ArkUI.ArkUI.Full 200 * @crossplatform 201 * @atomicservice 202 * @since 11 203 */ 204 static prop<T>(propName: string): SubscribedAbstractProperty<T>; 205 206 /** 207 * Like see Prop(), will create and initialize a new source property in AppStorage if missing 208 * Same as see LocalStorage.setAndProp() 209 * 210 * @param { string } propName 211 * @param { S } defaultValue 212 * @returns { SubscribedAbstractProperty<S> } 213 * @syscap SystemCapability.ArkUI.ArkUI.Full 214 * @since 7 215 * @deprecated since 10 216 * @useinstead AppStorage#setAndProp 217 * @see setAndProp 218 */ 219 static SetAndProp<S>(propName: string, defaultValue: S): SubscribedAbstractProperty<S>; 220 221 /** 222 * 223 * Like @see prop(), will create and initialize a new source property in AppStorage if missing 224 * Same as see LocalStorage.setAndProp() 225 * 226 * @param { string } propName - name of source property in AppStorage 227 * @param { T } defaultValue - value to be used for initializing if new creating new property in AppStorage. 228 * default value must be of type T, must not be undefined or null. 229 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 230 * return undefined if named property does not already exist in AppStorage. 231 * @syscap SystemCapability.ArkUI.ArkUI.Full 232 * @crossplatform 233 * @since 10 234 */ 235 /** 236 * 237 * Like @see prop(), will create and initialize a new source property in AppStorage if missing 238 * Same as see LocalStorage.setAndProp() 239 * 240 * @param { string } propName - name of source property in AppStorage 241 * @param { T } defaultValue - value to be used for initializing if new creating new property in AppStorage. 242 * default value must be of type T, must not be undefined or null. 243 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 244 * return undefined if named property does not already exist in AppStorage. 245 * @syscap SystemCapability.ArkUI.ArkUI.Full 246 * @crossplatform 247 * @atomicservice 248 * @since 11 249 */ 250 /** 251 * 252 * Like @see prop(), will create and initialize a new source property in AppStorage if missing 253 * Same as see LocalStorage.setAndProp() 254 * 255 * @param { string } propName - name of source property in AppStorage 256 * @param { T } defaultValue - value to be used for initializing new property in AppStorage. 257 * default value must be of type T, can be undefined or null. 258 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 259 * return undefined if named property does not exist in AppStorage. 260 * @syscap SystemCapability.ArkUI.ArkUI.Full 261 * @crossplatform 262 * @atomicservice 263 * @since 12 264 */ 265 static setAndProp<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 266 267 /** 268 * Checks if AppStorage has a property with given name 269 * returns true if property with given name exists 270 * same as ES6 Map.prototype.has() 271 * Same as see LocalStorage.has() 272 * 273 * @param { string } propName 274 * @returns { boolean } 275 * @syscap SystemCapability.ArkUI.ArkUI.Full 276 * @since 7 277 * @deprecated since 10 278 * @useinstead AppStorage#has 279 * @see has 280 */ 281 static Has(propName: string): boolean; 282 283 /** 284 * Checks if AppStorage has a property with given name 285 * returns true if property with given name exists 286 * same as ES6 Map.prototype.has() 287 * Same as see LocalStorage.has() 288 * 289 * @param { string } propName - searched property 290 * @returns { boolean } true if property with such name exists in AppStorage 291 * @syscap SystemCapability.ArkUI.ArkUI.Full 292 * @crossplatform 293 * @since 10 294 */ 295 /** 296 * Checks if AppStorage has a property with given name 297 * returns true if property with given name exists 298 * same as ES6 Map.prototype.has() 299 * Same as see LocalStorage.has() 300 * 301 * @param { string } propName - searched property 302 * @returns { boolean } true if property with such name exists in AppStorage 303 * @syscap SystemCapability.ArkUI.ArkUI.Full 304 * @crossplatform 305 * @atomicservice 306 * @since 11 307 */ 308 static has(propName: string): boolean; 309 310 /** 311 * Same as see LocalStorage.get() 312 * Obtain the value of property with given name, returns undefined if the property does not exist in AppStorage. 313 * @param { string } propName 314 * @returns { T | undefined } 315 * @syscap SystemCapability.ArkUI.ArkUI.Full 316 * @since 7 317 * @deprecated since 10 318 * @useinstead AppStorage#get 319 * @see get 320 */ 321 static Get<T>(propName: string): T | undefined; 322 323 /** 324 * Same as see LocalStorage.get() 325 * Obtain the value of property with given name, returns undefined if the property does not exist in AppStorage. 326 * 327 * @param { string } propName 328 * @returns { T | undefined } property value of type T if found or undefined 329 * @syscap SystemCapability.ArkUI.ArkUI.Full 330 * @crossplatform 331 * @since 10 332 */ 333 /** 334 * Same as see LocalStorage.get() 335 * Obtain the value of property with given name, returns undefined if the property does not exist in AppStorage. 336 * 337 * @param { string } propName 338 * @returns { T | undefined } property value of type T if found or undefined 339 * @syscap SystemCapability.ArkUI.ArkUI.Full 340 * @crossplatform 341 * @atomicservice 342 * @since 11 343 */ 344 static get<T>(propName: string): T | undefined; 345 346 /** 347 * Set value of given property in AppStorage 348 * Method sets nothing and returns false if property with this name does not exist 349 * or if newValue is `undefined` or `null`. 350 * Same as see LocalStorage.set() 351 * 352 * @param { string } propName 353 * @param { T } newValue 354 * @returns { boolean } 355 * @syscap SystemCapability.ArkUI.ArkUI.Full 356 * @since 7 357 * @deprecated since 10 358 * @useinstead AppStorage#set 359 * @see set 360 */ 361 static Set<T>(propName: string, newValue: T): boolean; 362 363 /** 364 * Set value of given property in AppStorage 365 * Method sets nothing and returns false if property with this name does not exist 366 * or if newValue is `undefined` or `null`. 367 * Same as see LocalStorage.set() 368 * 369 * @param { string } propName 370 * @param { T } newValue - must be of type T and must not be undefined or null 371 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 372 * @syscap SystemCapability.ArkUI.ArkUI.Full 373 * @crossplatform 374 * @since 10 375 */ 376 /** 377 * Set value of given property in AppStorage 378 * Method sets nothing and returns false if property with this name does not exist 379 * or if newValue is `undefined` or `null`. 380 * Same as see LocalStorage.set() 381 * 382 * @param { string } propName 383 * @param { T } newValue - must be of type T and must not be undefined or null 384 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 385 * @syscap SystemCapability.ArkUI.ArkUI.Full 386 * @crossplatform 387 * @atomicservice 388 * @since 11 389 */ 390 /** 391 * Set value of given property in AppStorage 392 * Method sets nothing and returns false if property with this name does not exist in AppStorage 393 * newValue can be undefined or null from API 12. 394 * Same as see LocalStorage.set() 395 * 396 * @param { string } propName 397 * @param { T } newValue - must be of type T, can be undefined or null 398 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 399 * @syscap SystemCapability.ArkUI.ArkUI.Full 400 * @crossplatform 401 * @atomicservice 402 * @since 12 403 */ 404 static set<T>(propName: string, newValue: T): boolean; 405 406 /** 407 * Set value of given property, if it exists, see set() . 408 * Add property if no property with given name in AppStorage,. yet, and initialize with given value. 409 * Do nothing if newValue is undefined or null 410 * see LocalStorage.setOrCreate() 411 * 412 * @param { string } propName 413 * @param { T } newValue 414 * @syscap SystemCapability.ArkUI.ArkUI.Full 415 * @since 7 416 * @deprecated since 10 417 * @useinstead AppStorage#setOrCreate 418 * @see setOrCreate 419 */ 420 static SetOrCreate<T>(propName: string, newValue: T): void; 421 422 /** 423 * Set value of given property, if it exists, see set() . 424 * Add property if no property with given name in AppStorage,. yet, and initialize with given value. 425 * Do nothing if newValue is undefined or null 426 * see LocalStorage.setOrCreate() 427 * 428 * @param { string } propName 429 * @param { T } newValue - must be of type T and must not be undefined or null 430 * @syscap SystemCapability.ArkUI.ArkUI.Full 431 * @crossplatform 432 * @since 10 433 */ 434 /** 435 * Set value of given property, if it exists, see set() . 436 * Add property if no property with given name in AppStorage,. yet, and initialize with given value. 437 * Do nothing if newValue is undefined or null 438 * see LocalStorage.setOrCreate() 439 * 440 * @param { string } propName 441 * @param { T } newValue - must be of type T and must not be undefined or null 442 * @syscap SystemCapability.ArkUI.ArkUI.Full 443 * @crossplatform 444 * @atomicservice 445 * @since 11 446 */ 447 /** 448 * Set value of given property, if it exists, see set() . 449 * Add property if no property with given name in AppStorage, and initialize with given value. 450 * newValue can be undefined or null from API 12 451 * see LocalStorage.setOrCreate() 452 * 453 * @param { string } propName 454 * @param { T } newValue - must be of type T, can be undefined or null 455 * @syscap SystemCapability.ArkUI.ArkUI.Full 456 * @crossplatform 457 * @atomicservice 458 * @since 12 459 */ 460 static setOrCreate<T>(propName: string, newValue: T): void; 461 462 /** 463 * Delete property with given name from AppStorage 464 * Use with caution: 465 * Before deleting a prop from AppStorage all its subscribers need to 466 * unsubscribe from the property. 467 * This method fails and returns false if given property still has subscribers 468 * Another reason for failing is unknown property name. 469 * Developer advise: 470 * Subscribers to a property in AppStorage are created with see link(), see prop() 471 * and also via @StorageLink and @StorageProp state variable decorators. 472 * That means as long as their is a @Component instance that uses such decorated variable 473 * or a sync relationship with a SubscribedAbstractProperty variable the property can not 474 * (and also should not!) be deleted from AppStorage. 475 * Same as see LocalStorage.delete() 476 * 477 * @param { string } propName 478 * @returns { boolean } 479 * @syscap SystemCapability.ArkUI.ArkUI.Full 480 * @since 7 481 * @deprecated since 10 482 * @useinstead AppStorage#delete 483 * @see delete 484 */ 485 static Delete(propName: string): boolean; 486 487 /** 488 * Delete property with given name from AppStorage 489 * Use with caution: 490 * Before deleting a prop from AppStorage all its subscribers need to 491 * unsubscribe from the property. 492 * This method fails and returns false if given property still has subscribers 493 * Another reason for failing is unknown property name. 494 * Developer advise: 495 * Subscribers to a property in AppStorage are created with see link(), see prop() 496 * and also via @StorageLink and @StorageProp state variable decorators. 497 * That means as long as their is a @Component instance that uses such decorated variable 498 * or a sync relationship with a SubscribedAbstractProperty variable the property can not 499 * (and also should not!) be deleted from AppStorage. 500 * Same as see LocalStorage.delete() 501 * 502 * @param { string } propName 503 * @returns { boolean } false if method failed 504 * @syscap SystemCapability.ArkUI.ArkUI.Full 505 * @crossplatform 506 * @since 10 507 */ 508 /** 509 * Delete property with given name from AppStorage 510 * Use with caution: 511 * Before deleting a prop from AppStorage all its subscribers need to 512 * unsubscribe from the property. 513 * This method fails and returns false if given property still has subscribers 514 * Another reason for failing is unknown property name. 515 * Developer advise: 516 * Subscribers to a property in AppStorage are created with see link(), see prop() 517 * and also via @StorageLink and @StorageProp state variable decorators. 518 * That means as long as their is a @Component instance that uses such decorated variable 519 * or a sync relationship with a SubscribedAbstractProperty variable the property can not 520 * (and also should not!) be deleted from AppStorage. 521 * Same as see LocalStorage.delete() 522 * 523 * @param { string } propName 524 * @returns { boolean } false if method failed 525 * @syscap SystemCapability.ArkUI.ArkUI.Full 526 * @crossplatform 527 * @atomicservice 528 * @since 11 529 */ 530 static delete(propName: string): boolean; 531 532 /** 533 * Provide names of all properties in AppStorage 534 * same as ES6 Map.prototype.keys() 535 * Same as see LocalStorage.keys() 536 * 537 * @returns { IterableIterator<string> } 538 * @syscap SystemCapability.ArkUI.ArkUI.Full 539 * @since 7 540 * @deprecated since 10 541 * @useinstead AppStorage#keys 542 * @see keys 543 */ 544 static Keys(): IterableIterator<string>; 545 546 /** 547 * Provide names of all properties in AppStorage 548 * same as ES6 Map.prototype.keys() 549 * Same as see LocalStorage.keys() 550 * 551 * @returns { IterableIterator<string> } return a Map Iterator 552 * @syscap SystemCapability.ArkUI.ArkUI.Full 553 * @crossplatform 554 * @since 10 555 */ 556 /** 557 * Provide names of all properties in AppStorage 558 * same as ES6 Map.prototype.keys() 559 * Same as see LocalStorage.keys() 560 * 561 * @returns { IterableIterator<string> } return a Map Iterator 562 * @syscap SystemCapability.ArkUI.ArkUI.Full 563 * @crossplatform 564 * @atomicservice 565 * @since 11 566 */ 567 static keys(): IterableIterator<string>; 568 569 /** 570 * Called when a cleanup occurs. 571 * 572 * @returns { boolean } 573 * @syscap SystemCapability.ArkUI.ArkUI.Full 574 * @since 7 575 * @deprecated since 9 576 * @useinstead AppStorage.Clear 577 */ 578 static staticClear(): boolean; 579 580 /** 581 * Delete all properties from the AppStorage. 582 * Precondition is that there are no subscribers, see Delete(). 583 * 584 * @returns { boolean } 585 * @syscap SystemCapability.ArkUI.ArkUI.Full 586 * @since 9 587 * @deprecated since 10 588 * @useinstead AppStorage#clear 589 * @see clear 590 */ 591 static Clear(): boolean; 592 593 /** 594 * Delete all properties from the AppStorage. 595 * Precondition is that there are no subscribers, see Delete(). 596 * 597 * @returns { boolean } false and deletes no properties if there is any property 598 * that still has subscribers. 599 * @syscap SystemCapability.ArkUI.ArkUI.Full 600 * @crossplatform 601 * @since 10 602 */ 603 /** 604 * Delete all properties from the AppStorage. 605 * Precondition is that there are no subscribers, see Delete(). 606 * 607 * @returns { boolean } false and deletes no properties if there is any property 608 * that still has subscribers. 609 * @syscap SystemCapability.ArkUI.ArkUI.Full 610 * @crossplatform 611 * @atomicservice 612 * @since 11 613 */ 614 static clear(): boolean; 615 616 /** 617 * Called when the data can be changed. 618 * 619 * @param { string } propName 620 * @returns { boolean } 621 * @syscap SystemCapability.ArkUI.ArkUI.Full 622 * @since 7 623 * @deprecated since 10 624 */ 625 static IsMutable(propName: string): boolean; 626 627 /** 628 * Method returns the number of properties currently in AppStorage 629 * 630 * @returns { number } 631 * @syscap SystemCapability.ArkUI.ArkUI.Full 632 * @since 7 633 * @deprecated since 10 634 * @useinstead AppStorage#size 635 * @see size 636 */ 637 static Size(): number; 638 639 /** 640 * Method returns the number of properties currently in AppStorage 641 * 642 * @returns { number } Returns the number of properties currently in AppStorage 643 * @syscap SystemCapability.ArkUI.ArkUI.Full 644 * @crossplatform 645 * @since 10 646 */ 647 /** 648 * Method returns the number of properties currently in AppStorage 649 * 650 * @returns { number } Returns the number of properties currently in AppStorage 651 * @syscap SystemCapability.ArkUI.ArkUI.Full 652 * @crossplatform 653 * @atomicservice 654 * @since 11 655 */ 656 static size(): number; 657} 658 659/** 660 * 661 * AbstractProperty can be understood as a handler or an alias 662 * to a property inside LocalStorage / AppStorage singleton 663 * allows to read the value with @see get and to change the 664 * value with @see set. 665 * 666 * Functions 667 * reads the referenced AppStorage/LocalStorage property value with given name @see get() 668 * write a new value to the AppStorage/LocalStorage property value @see set() 669 * returns the referenced AppStorage/LocalStorage property name @see info() 670 * 671 * Use ref or setAndRef to obtain a AbstractProperty. 672 * 673 * @interface AbstractProperty<T> 674 * @syscap SystemCapability.ArkUI.ArkUI.Full 675 * @crossplatform 676 * @atomicservice 677 * @since 12 678 */ 679declare interface AbstractProperty<T> { 680 /** 681 * reads value of the referenced AppStorage/LocalStorage property. 682 * 683 * @returns { T } value of the referenced AppStorage/LocalStorage property. 684 * @syscap SystemCapability.ArkUI.ArkUI.Full 685 * @crossplatform 686 * @atomicservice 687 * @since 12 688 */ 689 get(): T; 690 691 /** 692 * Set new value, must be of type T, can be 'undefined' or 'null'. 693 * Updates the value of the referenced AppStorage/LocalStorage property. 694 * 695 * @param { T } newValue new value set to AppStorage/LocalStorage 696 * @syscap SystemCapability.ArkUI.ArkUI.Full 697 * @crossplatform 698 * @atomicservice 699 * @since 12 700 */ 701 set(newValue: T): void; 702 703 /** 704 * returns the name of the referenced property 705 * 706 * @returns { string } name of the referenced property 707 * @syscap SystemCapability.ArkUI.ArkUI.Full 708 * @crossplatform 709 * @atomicservice 710 * @since 12 711 */ 712 info(): string; 713} 714 715/** 716 * Defines the subscribed abstract property. 717 * 718 * @syscap SystemCapability.ArkUI.ArkUI.Full 719 * @systemapi 720 * @since 7 721 */ 722/** 723 * SubscribedAbstractProperty<T> is the return value of 724 * - AppStorage static functions Link(), Prop(), SetAndLink(), and SetAndProp() 725 * - LocalStorage member methods link(), prop(), setAndLink(), and setAndProp() 726 * 'T' can be boolean, string, number or custom class. 727 * Main functions 728 * see get() reads the linked AppStorage/LocalStorage property value, 729 * see set(newValue) write a new value to the synched AppStorage/LocalStorage property 730 * see aboutToBeDeleted() ends the sync relationship with the AppStorage/LocalStorage property 731 * The app must call this function before the SubscribedAbstractProperty<T> object 732 * goes out of scope. 733 * 734 * @syscap SystemCapability.ArkUI.ArkUI.Full 735 * @form 736 * @since 9 737 */ 738/** 739 * SubscribedAbstractProperty<T> is the return value of 740 * - AppStorage static functions Link(), Prop(), SetAndLink(), and SetAndProp() 741 * - LocalStorage member methods link(), prop(), setAndLink(), and setAndProp() 742 * 'T' can be boolean, string, number or custom class. 743 * Main functions 744 * see get() reads the linked AppStorage/LocalStorage property value, 745 * see set(newValue) write a new value to the synched AppStorage/LocalStorage property 746 * see aboutToBeDeleted() ends the sync relationship with the AppStorage/LocalStorage property 747 * The app must call this function before the SubscribedAbstractProperty<T> object 748 * goes out of scope. 749 * 750 * @syscap SystemCapability.ArkUI.ArkUI.Full 751 * @crossplatform 752 * @form 753 * @since 10 754 */ 755/** 756 * SubscribedAbstractProperty<T> is the return value of 757 * - AppStorage static functions Link(), Prop(), SetAndLink(), and SetAndProp() 758 * - LocalStorage member methods link(), prop(), setAndLink(), and setAndProp() 759 * 'T' can be boolean, string, number or custom class. 760 * Main functions 761 * see get() reads the linked AppStorage/LocalStorage property value, 762 * see set(newValue) write a new value to the synched AppStorage/LocalStorage property 763 * see aboutToBeDeleted() ends the sync relationship with the AppStorage/LocalStorage property 764 * The app must call this function before the SubscribedAbstractProperty<T> object 765 * goes out of scope. 766 * 767 * @syscap SystemCapability.ArkUI.ArkUI.Full 768 * @crossplatform 769 * @form 770 * @atomicservice 771 * @since 11 772 */ 773declare abstract class SubscribedAbstractProperty<T> { 774 /** 775 * Setting Subscribers. 776 * 777 * @type { Set<number> } 778 * @syscap SystemCapability.ArkUI.ArkUI.Full 779 * @systemapi 780 * @since 7 781 */ 782 protected subscribers_: Set<number>; 783 784 /** 785 * Private user ID. 786 * 787 * @type { any } 788 * @syscap SystemCapability.ArkUI.ArkUI.Full 789 * @systemapi 790 * @since 7 791 */ 792 private id_; 793 794 /** 795 * Private user information. 796 * 797 * @type { ?any } 798 * @syscap SystemCapability.ArkUI.ArkUI.Full 799 * @systemapi 800 * @since 7 801 */ 802 private info_?; 803 804 /** 805 * @param { IPropertySubscriber } subscribeMe 806 * @param { string } info 807 * @syscap SystemCapability.ArkUI.ArkUI.Full 808 * @systemapi 809 * @since 7 810 */ 811 constructor( 812 /** 813 * Subscriber IPropertySubscriber. 814 * 815 * @syscap SystemCapability.ArkUI.ArkUI.Full 816 * @systemapi 817 * @since 7 818 * 819 */ 820 subscribeMe?: IPropertySubscriber, 821 /** 822 * Subscriber info. 823 * 824 * @syscap SystemCapability.ArkUI.ArkUI.Full 825 * @systemapi 826 * @since 7 827 * 828 */ 829 info?: string, 830 ); 831 832 /** 833 * Called when the subscriber ID is entered. 834 * 835 * @returns { number } 836 * @syscap SystemCapability.ArkUI.ArkUI.Full 837 * @systemapi 838 * @since 7 839 */ 840 id(): number; 841 842 /** 843 * Returns the property name, 844 * e.g. let link = AppStorage.Link("foo") then link.info() == "foo" 845 * 846 * @returns { string } the property name if set or undefined 847 * @syscap SystemCapability.ArkUI.ArkUI.Full 848 * @crossplatform 849 * @since 10 850 */ 851 /** 852 * Returns the property name, 853 * e.g. let link = AppStorage.Link("foo") then link.info() == "foo" 854 * 855 * @returns { string } the property name if set or undefined 856 * @syscap SystemCapability.ArkUI.ArkUI.Full 857 * @crossplatform 858 * @atomicservice 859 * @since 11 860 */ 861 info(): string; 862 863 /** 864 * Reads value of the sync'ed AppStorage/LocalStorage property. 865 * `let link : SubscribedAbstractProperty<string> =AppStorage.Link<string>("foo")` 866 * then `link.get()` returns the value of "foo" property in AppStorage. 867 * 868 * @returns { T } the value of the sync'ed AppStorage/LocalStorage property. 869 * @syscap SystemCapability.ArkUI.ArkUI.Full 870 * @form 871 * @since 9 872 */ 873 /** 874 * Reads value of the sync'ed AppStorage/LocalStorage property. 875 * `let link : SubscribedAbstractProperty<string> =AppStorage.Link<string>("foo")` 876 * then `link.get()` returns the value of "foo" property in AppStorage. 877 * 878 * @returns { T } the value of the sync'ed AppStorage/LocalStorage property. 879 * @syscap SystemCapability.ArkUI.ArkUI.Full 880 * @crossplatform 881 * @form 882 * @since 10 883 */ 884 /** 885 * Reads value of the sync'ed AppStorage/LocalStorage property. 886 * `let link : SubscribedAbstractProperty<string> =AppStorage.Link<string>("foo")` 887 * then `link.get()` returns the value of "foo" property in AppStorage. 888 * 889 * @returns { T } the value of the sync'ed AppStorage/LocalStorage property. 890 * @syscap SystemCapability.ArkUI.ArkUI.Full 891 * @crossplatform 892 * @form 893 * @atomicservice 894 * @since 11 895 */ 896 abstract get(): T; 897 898 /** 899 * Updates the value of value of the sync'ed AppStorage/LocalStorage property. 900 * Sets new value, must be of type T, and must not be 'undefined' or 'null'. 901 * `let link : SubscribedAbstractProperty<string> =AppStorage.Link<string>("foo")` 902 * then `link.set("Hello")` will set the value of "foo" property in AppStorage. 903 * 904 * @param { T } newValue 905 * @syscap SystemCapability.ArkUI.ArkUI.Full 906 * @form 907 * @since 9 908 */ 909 /** 910 * Updates the value of value of the sync'ed AppStorage/LocalStorage property. 911 * Sets new value, must be of type T, and must not be 'undefined' or 'null'. 912 * `let link : SubscribedAbstractProperty<string> =AppStorage.Link<string>("foo")` 913 * then `link.set("Hello")` will set the value of "foo" property in AppStorage. 914 * 915 * @param { T } newValue 916 * @syscap SystemCapability.ArkUI.ArkUI.Full 917 * @crossplatform 918 * @form 919 * @since 10 920 */ 921 /** 922 * Updates the value of value of the sync'ed AppStorage/LocalStorage property. 923 * Sets new value, must be of type T, and must not be 'undefined' or 'null'. 924 * `let link : SubscribedAbstractProperty<string> =AppStorage.Link<string>("foo")` 925 * then `link.set("Hello")` will set the value of "foo" property in AppStorage. 926 * 927 * @param { T } newValue 928 * @syscap SystemCapability.ArkUI.ArkUI.Full 929 * @crossplatform 930 * @form 931 * @atomicservice 932 * @since 11 933 */ 934 /** 935 * Updates the value of value of the sync'ed AppStorage/LocalStorage property. 936 * Sets new value, must be of type T, can be undefined or null. 937 * `let link : SubscribedAbstractProperty<string> =AppStorage.Link<string>("foo")` 938 * then `link.set("Hello")` will set the value of "foo" property in AppStorage. 939 * 940 * @param { T } newValue 941 * @syscap SystemCapability.ArkUI.ArkUI.Full 942 * @crossplatform 943 * @form 944 * @atomicservice 945 * @since 12 946 */ 947 abstract set(newValue: T): void; 948 949 /** 950 * Called when a two-way synchronization is created. 951 * 952 * @param { IPropertySubscriber } subscribeMe 953 * @param { string } info 954 * @returns { SyncedPropertyTwoWay<T> } 955 * @syscap SystemCapability.ArkUI.ArkUI.Full 956 * @systemapi 957 * @since 7 958 */ 959 createTwoWaySync(subscribeMe?: IPropertySubscriber, info?: string): SyncedPropertyTwoWay<T>; 960 961 /** 962 * Called when a one-way synchronization is created. 963 * 964 * @param { IPropertySubscriber } subscribeMe 965 * @param { string } info 966 * @returns { SyncedPropertyOneWay<T> } 967 * @syscap SystemCapability.ArkUI.ArkUI.Full 968 * @systemapi 969 * @since 7 970 */ 971 createOneWaySync(subscribeMe?: IPropertySubscriber, info?: string): SyncedPropertyOneWay<T>; 972 973 /** 974 * Called when the subscriber is unlinked. 975 * 976 * @param { number } subscriberId 977 * @syscap SystemCapability.ArkUI.ArkUI.Full 978 * @systemapi 979 * @since 7 980 */ 981 unlinkSuscriber(subscriberId: number): void; 982 983 /** 984 * Called when the notification has changed. 985 * 986 * @param { T } newValue 987 * @syscap SystemCapability.ArkUI.ArkUI.Full 988 * @systemapi 989 * @since 7 990 */ 991 protected notifyHasChanged(newValue: T): void; 992 993 /** 994 * Called when the notification property is read. 995 * 996 * @syscap SystemCapability.ArkUI.ArkUI.Full 997 * @systemapi 998 * @since 7 999 */ 1000 protected notifyPropertyRead(): void; 1001 1002 /** 1003 * Called when the number of users is queried. 1004 * 1005 * @returns { number } 1006 * @syscap SystemCapability.ArkUI.ArkUI.Full 1007 * @systemapi 1008 * @since 7 1009 */ 1010 numberOfSubscrbers(): number; 1011 1012 /** 1013 * An app needs to call this function before the instance of SubscribedAbstractProperty 1014 * goes out of scope / is subject to garbage collection. Its purpose is to unregister the 1015 * variable from the two-way/one-way sync relationship that AppStorage/LocalStorage.link()/prop() 1016 * and related functions create. 1017 * 1018 * @syscap SystemCapability.ArkUI.ArkUI.Full 1019 * @crossplatform 1020 * @since 10 1021 */ 1022 /** 1023 * An app needs to call this function before the instance of SubscribedAbstractProperty 1024 * goes out of scope / is subject to garbage collection. Its purpose is to unregister the 1025 * variable from the two-way/one-way sync relationship that AppStorage/LocalStorage.link()/prop() 1026 * and related functions create. 1027 * 1028 * @syscap SystemCapability.ArkUI.ArkUI.Full 1029 * @crossplatform 1030 * @atomicservice 1031 * @since 11 1032 */ 1033 abstract aboutToBeDeleted(): void; 1034} 1035 1036/** 1037 * Provides an interface for attribute subscribers. 1038 * 1039 * @interface IPropertySubscriber 1040 * @syscap SystemCapability.ArkUI.ArkUI.Full 1041 * @systemapi 1042 * @since 7 1043 */ 1044interface IPropertySubscriber { 1045 /** 1046 * Called when the ID of the property subscriber is queried. 1047 * 1048 * @returns { number } 1049 * @syscap SystemCapability.ArkUI.ArkUI.Full 1050 * @systemapi 1051 * @since 7 1052 */ 1053 id(): number; 1054 1055 /** 1056 * Provides a single attribute change user interface. 1057 * 1058 * @param { IPropertySubscriber } owningView 1059 * @syscap SystemCapability.ArkUI.ArkUI.Full 1060 * @systemapi 1061 * @since 7 1062 */ 1063 aboutToBeDeleted(owningView?: IPropertySubscriber): void; 1064} 1065 1066/** 1067 * Defines the state value. 1068 * 1069 * @extends SubscribedAbstractProperty<T> 1070 * @implements ISinglePropertyChangeSubscriber<T> 1071 * @syscap SystemCapability.ArkUI.ArkUI.Full 1072 * @systemapi 1073 * @since 7 1074 */ 1075declare class SyncedPropertyTwoWay<T> 1076 extends SubscribedAbstractProperty<T> 1077 implements ISinglePropertyChangeSubscriber<T> 1078{ 1079 /** 1080 * Sources of synchronization attributes bidirectionally. 1081 * 1082 * @type { any } 1083 * @syscap SystemCapability.ArkUI.ArkUI.Full 1084 * @systemapi 1085 * @since 7 1086 */ 1087 private source_; 1088 1089 /** 1090 * constructor parameters. 1091 * 1092 * @param { SubscribedAbstractProperty<T> } source 1093 * @param { IPropertySubscriber } subscribeMe 1094 * @param { string } info 1095 * @syscap SystemCapability.ArkUI.ArkUI.Full 1096 * @systemapi 1097 * @since 7 1098 */ 1099 constructor(source: SubscribedAbstractProperty<T>, subscribeMe?: IPropertySubscriber, info?: string); 1100 1101 /** 1102 * Called when processing information about to be deleted. 1103 * 1104 * @param { IPropertySubscriber } unsubscribeMe 1105 * @syscap SystemCapability.ArkUI.ArkUI.Full 1106 * @systemapi 1107 * @since 7 1108 */ 1109 aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber): void; 1110 1111 /** 1112 * Information Changed. 1113 * 1114 * @param { T } newValue 1115 * @syscap SystemCapability.ArkUI.ArkUI.Full 1116 * @systemapi 1117 * @since 7 1118 */ 1119 hasChanged(newValue: T): void; 1120 1121 /** 1122 * Called when data is obtained. 1123 * 1124 * @returns { T } 1125 * @syscap SystemCapability.ArkUI.ArkUI.Full 1126 * @systemapi 1127 * @since 7 1128 */ 1129 get(): T; 1130 1131 /** 1132 * Called when data is created. 1133 * 1134 * @param { T } newValue 1135 * @syscap SystemCapability.ArkUI.ArkUI.Full 1136 * @systemapi 1137 * @since 7 1138 */ 1139 set(newValue: T): void; 1140} 1141 1142/** 1143 * Defines the prop state value. 1144 * 1145 * @extends SubscribedAbstractProperty<T> 1146 * @implements ISinglePropertyChangeSubscriber<T> 1147 * @syscap SystemCapability.ArkUI.ArkUI.Full 1148 * @systemapi 1149 * @since 7 1150 */ 1151declare class SyncedPropertyOneWay<T> 1152 extends SubscribedAbstractProperty<T> 1153 implements ISinglePropertyChangeSubscriber<T> 1154{ 1155 /** 1156 * Pack value for single-item binding. 1157 * 1158 * @type { any } 1159 * @syscap SystemCapability.ArkUI.ArkUI.Full 1160 * @systemapi 1161 * @since 7 1162 */ 1163 private wrappedValue_; 1164 1165 /** 1166 * Sources of synchronization attributes bidirectionally. 1167 * 1168 * @type { any } 1169 * @syscap SystemCapability.ArkUI.ArkUI.Full 1170 * @systemapi 1171 * @since 7 1172 */ 1173 private source_; 1174 1175 /** 1176 * Constructor parameters. 1177 * 1178 * @param { SubscribedAbstractProperty<T> } source 1179 * @param { IPropertySubscriber } subscribeMe 1180 * @param { string } info 1181 * @syscap SystemCapability.ArkUI.ArkUI.Full 1182 * @systemapi 1183 * @since 7 1184 */ 1185 constructor(source: SubscribedAbstractProperty<T>, subscribeMe?: IPropertySubscriber, info?: string); 1186 1187 /** 1188 * Called when processing information about to be deleted. 1189 * 1190 * @param { IPropertySubscriber } unsubscribeMe 1191 * @syscap SystemCapability.ArkUI.ArkUI.Full 1192 * @systemapi 1193 * @since 7 1194 */ 1195 aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber): void; 1196 1197 /** 1198 * Information Changed. 1199 * 1200 * @param { T } newValue 1201 * @syscap SystemCapability.ArkUI.ArkUI.Full 1202 * @systemapi 1203 * @since 7 1204 */ 1205 hasChanged(newValue: T): void; 1206 1207 /** 1208 * Called when data is obtained. 1209 * 1210 * @returns { T } 1211 * @syscap SystemCapability.ArkUI.ArkUI.Full 1212 * @systemapi 1213 * @since 7 1214 */ 1215 get(): T; 1216 1217 /** 1218 * Called when data is created. 1219 * 1220 * @param { T } newValue 1221 * @syscap SystemCapability.ArkUI.ArkUI.Full 1222 * @systemapi 1223 * @since 7 1224 */ 1225 set(newValue: T): void; 1226} 1227 1228/** 1229 * Defines the subscriber. 1230 * 1231 * @extends IPropertySubscriber 1232 * @interface ISinglePropertyChangeSubscriber 1233 * @syscap SystemCapability.ArkUI.ArkUI.Full 1234 * @systemapi 1235 * @since 7 1236 */ 1237interface ISinglePropertyChangeSubscriber<T> extends IPropertySubscriber { 1238 /** 1239 * Provides a single attribute change user interface. 1240 * 1241 * @param { T } newValue 1242 * @syscap SystemCapability.ArkUI.ArkUI.Full 1243 * @systemapi 1244 * @since 7 1245 */ 1246 hasChanged(newValue: T): void; 1247} 1248 1249/** 1250 * Defines the Subscribale base class. 1251 * 1252 * @syscap SystemCapability.ArkUI.ArkUI.Full 1253 * @systemapi 1254 * @since 7 1255 */ 1256declare abstract class SubscribaleAbstract { 1257 /** 1258 * Returns the ownership attribute set by the. 1259 * 1260 * @type { Set<number> } 1261 * @syscap SystemCapability.ArkUI.ArkUI.Full 1262 * @systemapi 1263 * @since 7 1264 */ 1265 private owningProperties_: Set<number>; 1266 1267 /** 1268 * Constructor. 1269 * 1270 * @syscap SystemCapability.ArkUI.ArkUI.Full 1271 * @systemapi 1272 * @since 7 1273 */ 1274 constructor(); 1275 1276 /** 1277 * Called when the notification property has changed. 1278 * 1279 * @param { string } propName 1280 * @param { any } newValue 1281 * @syscap SystemCapability.ArkUI.ArkUI.Full 1282 * @systemapi 1283 * @since 7 1284 */ 1285 protected notifyPropertyHasChanged(propName: string, newValue: any): void; 1286 1287 /** 1288 * Called when adding an already owned property. 1289 * 1290 * @param { IPropertySubscriber } subscriber 1291 * @syscap SystemCapability.ArkUI.ArkUI.Full 1292 * @systemapi 1293 * @since 7 1294 */ 1295 public addOwningProperty(subscriber: IPropertySubscriber): void; 1296 1297 /** 1298 * Called when an already owned property is deleted. 1299 * 1300 * @param { IPropertySubscriber } property 1301 * @syscap SystemCapability.ArkUI.ArkUI.Full 1302 * @systemapi 1303 * @since 7 1304 */ 1305 public removeOwningProperty(property: IPropertySubscriber): void; 1306 1307 /** 1308 * Called when an already owned property is deleted by ID 1309 * 1310 * @param { number } subscriberId 1311 * @syscap SystemCapability.ArkUI.ArkUI.Full 1312 * @systemapi 1313 * @since 7 1314 */ 1315 public removeOwningPropertyById(subscriberId: number): void; 1316} 1317 1318/** 1319 * EnvProps object 1320 * 1321 * @interface EnvPropsOptions 1322 * @syscap SystemCapability.ArkUI.ArkUI.Full 1323 * @crossplatform 1324 * @since 10 1325 */ 1326/** 1327 * EnvProps object 1328 * 1329 * @interface EnvPropsOptions 1330 * @syscap SystemCapability.ArkUI.ArkUI.Full 1331 * @crossplatform 1332 * @atomicservice 1333 * @since 11 1334 */ 1335declare interface EnvPropsOptions { 1336 /** 1337 * Property name of Environment variable 1338 * 1339 * @type { string } 1340 * @syscap SystemCapability.ArkUI.ArkUI.Full 1341 * @crossplatform 1342 * @since 10 1343 */ 1344 /** 1345 * Property name of Environment variable 1346 * 1347 * @type { string } 1348 * @syscap SystemCapability.ArkUI.ArkUI.Full 1349 * @crossplatform 1350 * @atomicservice 1351 * @since 11 1352 */ 1353 key: string; 1354 1355 /** 1356 * DefaultValue is the default value if cannot get the environment property value 1357 * 1358 * @type { number | string | boolean } 1359 * @syscap SystemCapability.ArkUI.ArkUI.Full 1360 * @crossplatform 1361 * @since 10 1362 */ 1363 /** 1364 * DefaultValue is the default value if cannot get the environment property value 1365 * 1366 * @type { number | string | boolean } 1367 * @syscap SystemCapability.ArkUI.ArkUI.Full 1368 * @crossplatform 1369 * @atomicservice 1370 * @since 11 1371 */ 1372 defaultValue: number | string | boolean; 1373} 1374 1375/** 1376 * Defines the Environment interface. 1377 * 1378 * @syscap SystemCapability.ArkUI.ArkUI.Full 1379 * @since 7 1380 */ 1381/** 1382 * Defines the Environment interface. 1383 * 1384 * @syscap SystemCapability.ArkUI.ArkUI.Full 1385 * @crossplatform 1386 * @since 10 1387 */ 1388/** 1389 * Defines the Environment interface. 1390 * 1391 * @syscap SystemCapability.ArkUI.ArkUI.Full 1392 * @crossplatform 1393 * @atomicservice 1394 * @since 11 1395 */ 1396declare class Environment { 1397 /** 1398 * Constructor. 1399 * 1400 * @syscap SystemCapability.ArkUI.ArkUI.Full 1401 * @systemapi 1402 * @since 7 1403 */ 1404 constructor(); 1405 1406 /** 1407 * Called when a property value is added to Environment. 1408 * 1409 * @param { string } key 1410 * @param { S } value 1411 * @returns { boolean } 1412 * @syscap SystemCapability.ArkUI.ArkUI.Full 1413 * @since 7 1414 * @deprecated since 10 1415 * @useinstead Environment#envProp 1416 */ 1417 static EnvProp<S>(key: string, value: S): boolean; 1418 1419 /** 1420 * Creates a new property in AppStorage. The UI framework implementation takes care of updating 1421 * its value whenever the named device environment property changes. Recommended use is at app startup. 1422 * The function call fails and returns false if a property with given name exists in AppStorage already. 1423 * It is wrong API use to access a property with given name in AppStorage before calling Environment.envProp. 1424 * 1425 * @param { string } key - environment property 1426 * @param { S } value - is the default value if cannot get the environment property value 1427 * @returns { boolean } false if method failed 1428 * @syscap SystemCapability.ArkUI.ArkUI.Full 1429 * @crossplatform 1430 * @since 10 1431 */ 1432 /** 1433 * Creates a new property in AppStorage. The UI framework implementation takes care of updating 1434 * its value whenever the named device environment property changes. Recommended use is at app startup. 1435 * The function call fails and returns false if a property with given name exists in AppStorage already. 1436 * It is wrong API use to access a property with given name in AppStorage before calling Environment.envProp. 1437 * 1438 * @param { string } key - environment property 1439 * @param { S } value - is the default value if cannot get the environment property value 1440 * @returns { boolean } false if method failed 1441 * @syscap SystemCapability.ArkUI.ArkUI.Full 1442 * @crossplatform 1443 * @atomicservice 1444 * @since 11 1445 */ 1446 static envProp<S>(key: string, value: S): boolean; 1447 1448 /** 1449 * Called when multiple property values are added to Environment. 1450 * 1451 * @param { {key: string;defaultValue: any;}[] } props 1452 * @syscap SystemCapability.ArkUI.ArkUI.Full 1453 * @since 7 1454 * @deprecated since 10 1455 * @useinstead Environment#envProps 1456 */ 1457 static EnvProps( 1458 props: { 1459 key: string; 1460 defaultValue: any; 1461 }[], 1462 ): void; 1463 1464 /** 1465 * Called when multiple property values are added to Environment. 1466 * 1467 * @param { EnvPropsOptions[] } props 1468 * @syscap SystemCapability.ArkUI.ArkUI.Full 1469 * @crossplatform 1470 * @since 10 1471 */ 1472 /** 1473 * Called when multiple property values are added to Environment. 1474 * 1475 * @param { EnvPropsOptions[] } props 1476 * @syscap SystemCapability.ArkUI.ArkUI.Full 1477 * @crossplatform 1478 * @atomicservice 1479 * @since 11 1480 */ 1481 static envProps(props: EnvPropsOptions[]): void; 1482 1483 /** 1484 * returns an Array<string> of all environment property keys 1485 * 1486 * @returns { Array<string> } 1487 * @syscap SystemCapability.ArkUI.ArkUI.Full 1488 * @since 7 1489 * @deprecated since 10 1490 * @useinstead Environment#keys 1491 */ 1492 static Keys(): Array<string>; 1493 1494 /** 1495 * returns an Array<string> of all environment property keys 1496 * 1497 * @returns { Array<string> } all environment property keys 1498 * @syscap SystemCapability.ArkUI.ArkUI.Full 1499 * @crossplatform 1500 * @since 10 1501 */ 1502 /** 1503 * returns an Array<string> of all environment property keys 1504 * 1505 * @returns { Array<string> } all environment property keys 1506 * @syscap SystemCapability.ArkUI.ArkUI.Full 1507 * @crossplatform 1508 * @atomicservice 1509 * @since 11 1510 */ 1511 static keys(): Array<string>; 1512} 1513 1514/** 1515 * PersistProps object 1516 * 1517 * @interface PersistPropsOptions 1518 * @syscap SystemCapability.ArkUI.ArkUI.Full 1519 * @crossplatform 1520 * @since 10 1521 */ 1522/** 1523 * PersistProps object 1524 * 1525 * @interface PersistPropsOptions 1526 * @syscap SystemCapability.ArkUI.ArkUI.Full 1527 * @crossplatform 1528 * @atomicservice 1529 * @since 11 1530 */ 1531declare interface PersistPropsOptions { 1532 /** 1533 * Property name 1534 * 1535 * @type { string } 1536 * @syscap SystemCapability.ArkUI.ArkUI.Full 1537 * @crossplatform 1538 * @since 10 1539 */ 1540 /** 1541 * Property name 1542 * 1543 * @type { string } 1544 * @syscap SystemCapability.ArkUI.ArkUI.Full 1545 * @crossplatform 1546 * @atomicservice 1547 * @since 11 1548 */ 1549 key: string; 1550 1551 /** 1552 * If AppStorage does not include this property it will be initialized with this value 1553 * 1554 * @type { number | string | boolean | Object } 1555 * @syscap SystemCapability.ArkUI.ArkUI.Full 1556 * @crossplatform 1557 * @since 10 1558 */ 1559 /** 1560 * If AppStorage does not include this property it will be initialized with this value 1561 * 1562 * @type { number | string | boolean | Object } 1563 * @syscap SystemCapability.ArkUI.ArkUI.Full 1564 * @crossplatform 1565 * @atomicservice 1566 * @since 11 1567 */ 1568 defaultValue: number | string | boolean | Object; 1569} 1570 1571/** 1572 * Defines the PersistentStorage interface. 1573 * 1574 * @syscap SystemCapability.ArkUI.ArkUI.Full 1575 * @since 7 1576 */ 1577/** 1578 * Defines the PersistentStorage interface. 1579 * 1580 * @syscap SystemCapability.ArkUI.ArkUI.Full 1581 * @crossplatform 1582 * @since 10 1583 */ 1584/** 1585 * Defines the PersistentStorage interface. 1586 * 1587 * @syscap SystemCapability.ArkUI.ArkUI.Full 1588 * @crossplatform 1589 * @atomicservice 1590 * @since 11 1591 */ 1592declare class PersistentStorage { 1593 /** 1594 * Constructor parameters. 1595 * 1596 * @param { AppStorage } appStorage 1597 * @param { Storage } storage 1598 * @syscap SystemCapability.ArkUI.ArkUI.Full 1599 * @systemapi 1600 * @since 7 1601 */ 1602 constructor(appStorage: AppStorage, storage: Storage); 1603 1604 /** 1605 * Called when a persistence property is stored. 1606 * 1607 * @param { string } key 1608 * @param { T } defaultValue 1609 * @syscap SystemCapability.ArkUI.ArkUI.Full 1610 * @since 7 1611 * @deprecated since 10 1612 * @useinstead PersistentStorage#persistProp 1613 */ 1614 static PersistProp<T>(key: string, defaultValue: T): void; 1615 1616 /** 1617 * Add property 'key' to AppStorage properties whose current value will be 1618 * persistent. 1619 * If AppStorage does not include this property it will be added and initializes 1620 * with given value 1621 * 1622 * @param { string } key - property name 1623 * @param { T } defaultValue - If AppStorage does not include this property it will be initialized with this value 1624 * @syscap SystemCapability.ArkUI.ArkUI.Full 1625 * @crossplatform 1626 * @since 10 1627 */ 1628 /** 1629 * Add property 'key' to AppStorage properties whose current value will be 1630 * persistent. 1631 * If AppStorage does not include this property it will be added and initializes 1632 * with given value 1633 * 1634 * @param { string } key - property name 1635 * @param { T } defaultValue - If AppStorage does not include this property it will be initialized with this value 1636 * @syscap SystemCapability.ArkUI.ArkUI.Full 1637 * @crossplatform 1638 * @atomicservice 1639 * @since 11 1640 */ 1641 static persistProp<T>(key: string, defaultValue: T): void; 1642 1643 /** 1644 * Called when a property is deleted. 1645 * 1646 * @param { string } key 1647 * @syscap SystemCapability.ArkUI.ArkUI.Full 1648 * @since 7 1649 * @deprecated since 10 1650 * @useinstead PersistentStorage#deleteProp 1651 */ 1652 static DeleteProp(key: string): void; 1653 1654 /** 1655 * Reverse of @see persistProp 1656 * 1657 * @param { string } key - no longer persist the property named key 1658 * @syscap SystemCapability.ArkUI.ArkUI.Full 1659 * @crossplatform 1660 * @since 10 1661 */ 1662 /** 1663 * Reverse of @see persistProp 1664 * 1665 * @param { string } key - no longer persist the property named key 1666 * @syscap SystemCapability.ArkUI.ArkUI.Full 1667 * @crossplatform 1668 * @atomicservice 1669 * @since 11 1670 */ 1671 static deleteProp(key: string): void; 1672 1673 /** 1674 * Called when multiple persistence properties are stored. 1675 * 1676 * @param { {key: string;defaultValue: any;}[] } properties 1677 * @syscap SystemCapability.ArkUI.ArkUI.Full 1678 * @since 7 1679 * @deprecated since 10 1680 * @useinstead PersistentStorage#PersistProps 1681 */ 1682 static PersistProps( 1683 properties: { 1684 key: string; 1685 defaultValue: any; 1686 }[], 1687 ): void; 1688 1689 /** 1690 * Persist given AppStorage properties with given names. 1691 * If a property does not exist in AppStorage, add it and initialize it with given value 1692 * works as @see persistProp for multiple properties. 1693 * 1694 * @param { PersistPropsOptions[] } props 1695 * @syscap SystemCapability.ArkUI.ArkUI.Full 1696 * @crossplatform 1697 * @since 10 1698 */ 1699 /** 1700 * Persist given AppStorage properties with given names. 1701 * If a property does not exist in AppStorage, add it and initialize it with given value 1702 * works as @see persistProp for multiple properties. 1703 * 1704 * @param { PersistPropsOptions[] } props 1705 * @syscap SystemCapability.ArkUI.ArkUI.Full 1706 * @crossplatform 1707 * @atomicservice 1708 * @since 11 1709 */ 1710 static persistProps(props: PersistPropsOptions[]): void; 1711 1712 /** 1713 * Inform persisted AppStorage property names 1714 * returns an Array<string> of persisted AppStorage property names 1715 * 1716 * @returns { Array<string> } 1717 * @syscap SystemCapability.ArkUI.ArkUI.Full 1718 * @since 7 1719 * @deprecated since 10 1720 * @useinstead PersistentStorage#keys 1721 */ 1722 static Keys(): Array<string>; 1723 1724 /** 1725 * Inform persisted AppStorage property names 1726 * returns an Array<string> of persisted AppStorage property names 1727 * 1728 * @returns { Array<string> } array of AppStorage keys 1729 * @syscap SystemCapability.ArkUI.ArkUI.Full 1730 * @crossplatform 1731 * @since 10 1732 */ 1733 /** 1734 * Inform persisted AppStorage property names 1735 * 1736 * @returns { Array<string> } array of AppStorage keys 1737 * @syscap SystemCapability.ArkUI.ArkUI.Full 1738 * @crossplatform 1739 * @atomicservice 1740 * @since 11 1741 */ 1742 static keys(): Array<string>; 1743} 1744 1745/** 1746 * Used for ide. 1747 * 1748 * @syscap SystemCapability.ArkUI.ArkUI.Full 1749 * @systemapi 1750 * @since 7 1751 */ 1752declare const appStorage: AppStorage; 1753 1754/** 1755 * LocalStorage 1756 * Class implements a Map of ObservableObjectBase UI state variables. 1757 * Instances can be created to manage UI state within a limited "local" 1758 * access, and life cycle as defined by the app. 1759 * AppStorage singleton is sub-class of LocalStorage for 1760 * UI state of app-wide access and same life cycle as the app. 1761 * 1762 * @syscap SystemCapability.ArkUI.ArkUI.Full 1763 * @form 1764 * @since 9 1765 */ 1766/** 1767 * LocalStorage 1768 * Class implements a Map of ObservableObjectBase UI state variables. 1769 * Instances can be created to manage UI state within a limited "local" 1770 * access, and life cycle as defined by the app. 1771 * AppStorage singleton is sub-class of LocalStorage for 1772 * UI state of app-wide access and same life cycle as the app. 1773 * 1774 * @syscap SystemCapability.ArkUI.ArkUI.Full 1775 * @crossplatform 1776 * @form 1777 * @since 10 1778 */ 1779/** 1780 * LocalStorage 1781 * Class implements a Map of ObservableObjectBase UI state variables. 1782 * Instances can be created to manage UI state within a limited "local" 1783 * access, and life cycle as defined by the app. 1784 * AppStorage singleton is sub-class of LocalStorage for 1785 * UI state of app-wide access and same life cycle as the app. 1786 * 1787 * @syscap SystemCapability.ArkUI.ArkUI.Full 1788 * @crossplatform 1789 * @form 1790 * @atomicservice 1791 * @since 11 1792 */ 1793declare class LocalStorage { 1794 /** 1795 * Construct new instance of LocalStorage 1796 * initialize with all properties and their values that Object.keys(params) returns 1797 * Property values must not be undefined. 1798 * 1799 * @param { Object } [initializingProperties] - Object containing keys and values. see set() for valid values 1800 * @syscap SystemCapability.ArkUI.ArkUI.Full 1801 * @form 1802 * @since 9 1803 */ 1804 /** 1805 * Construct new instance of LocalStorage 1806 * initialize with all properties and their values that Object.keys(params) returns 1807 * Property values must not be undefined. 1808 * 1809 * @param { Object } [initializingProperties] - Object containing keys and values. see set() for valid values 1810 * @syscap SystemCapability.ArkUI.ArkUI.Full 1811 * @crossplatform 1812 * @form 1813 * @since 10 1814 */ 1815 /** 1816 * Construct new instance of LocalStorage 1817 * initialize with all properties and their values that Object.keys(params) returns 1818 * Property values must not be undefined. 1819 * 1820 * @param { Object } [initializingProperties] - Object containing keys and values. see set() for valid values 1821 * @syscap SystemCapability.ArkUI.ArkUI.Full 1822 * @crossplatform 1823 * @form 1824 * @atomicservice 1825 * @since 11 1826 */ 1827 constructor(initializingProperties?: Object); 1828 1829 /** 1830 * Get current LocalStorage shared from stage. 1831 * 1832 * @returns { LocalStorage } 1833 * @syscap SystemCapability.ArkUI.ArkUI.Full 1834 * @StageModelOnly 1835 * @form 1836 * @since 9 1837 * @deprecated since 10 1838 * @useinstead LocalStorage#getShared 1839 */ 1840 static GetShared(): LocalStorage; 1841 1842 /** 1843 * Get current LocalStorage shared from stage. 1844 * 1845 * @returns { LocalStorage } instance 1846 * @syscap SystemCapability.ArkUI.ArkUI.Full 1847 * @StageModelOnly 1848 * @crossplatform 1849 * @form 1850 * @since 10 1851 */ 1852 /** 1853 * Get current LocalStorage shared from stage. 1854 * 1855 * @returns { LocalStorage } instance 1856 * @syscap SystemCapability.ArkUI.ArkUI.Full 1857 * @StageModelOnly 1858 * @crossplatform 1859 * @form 1860 * @atomicservice 1861 * @since 11 1862 */ 1863 static getShared(): LocalStorage; 1864 1865 /** 1866 * Obtain a handler or an alias to LocalStorage property with given name. 1867 * 1868 * @param { string } propName LocalStorage property name 1869 * @returns { AbstractProperty<T> | undefined } AbstractProperty object if property with given name exists 1870 * return undefined otherwise. 1871 * @syscap SystemCapability.ArkUI.ArkUI.Full 1872 * @crossplatform 1873 * @atomicservice 1874 * @since 12 1875 */ 1876 public ref<T>(propName: string): AbstractProperty<T> | undefined; 1877 1878 /** 1879 * Obtain a handler or an alias to LocalStorage property with given name. 1880 * 1881 * If property does not exist in LocalStorage, create it with given default value. 1882 * 1883 * @param { string } propName LocalStorage property name 1884 * @param { T } defaultValue If property does not exist in LocalStorage, 1885 * create it with given default value. 1886 * @returns { AbstractProperty<T> } AbstractProperty object 1887 * @syscap SystemCapability.ArkUI.ArkUI.Full 1888 * @crossplatform 1889 * @atomicservice 1890 * @since 12 1891 */ 1892 public setAndRef<T>(propName: string, defaultValue: T): AbstractProperty<T>; 1893 1894 /** 1895 * Check if LocalStorage has a property with given name 1896 * return true if property with given name exists 1897 * same as ES6 Map.prototype.has() 1898 * 1899 * @param { string } propName - searched property 1900 * @returns { boolean } true if property with such name exists in LocalStorage 1901 * @syscap SystemCapability.ArkUI.ArkUI.Full 1902 * @form 1903 * @since 9 1904 */ 1905 /** 1906 * Check if LocalStorage has a property with given name 1907 * return true if property with given name exists 1908 * same as ES6 Map.prototype.has() 1909 * 1910 * @param { string } propName - searched property 1911 * @returns { boolean } true if property with such name exists in LocalStorage 1912 * @syscap SystemCapability.ArkUI.ArkUI.Full 1913 * @crossplatform 1914 * @form 1915 * @since 10 1916 */ 1917 /** 1918 * Check if LocalStorage has a property with given name 1919 * return true if property with given name exists 1920 * same as ES6 Map.prototype.has() 1921 * 1922 * @param { string } propName - searched property 1923 * @returns { boolean } true if property with such name exists in LocalStorage 1924 * @syscap SystemCapability.ArkUI.ArkUI.Full 1925 * @crossplatform 1926 * @form 1927 * @atomicservice 1928 * @since 11 1929 */ 1930 has(propName: string): boolean; 1931 1932 /** 1933 * Provide names of all properties in LocalStorage 1934 * same as ES6 Map.prototype.keys() 1935 * 1936 * @returns { IterableIterator<string> } return a Map Iterator 1937 * @syscap SystemCapability.ArkUI.ArkUI.Full 1938 * @form 1939 * @since 9 1940 */ 1941 /** 1942 * Provide names of all properties in LocalStorage 1943 * same as ES6 Map.prototype.keys() 1944 * 1945 * @returns { IterableIterator<string> } return a Map Iterator 1946 * @syscap SystemCapability.ArkUI.ArkUI.Full 1947 * @crossplatform 1948 * @form 1949 * @since 10 1950 */ 1951 /** 1952 * Provide names of all properties in LocalStorage 1953 * same as ES6 Map.prototype.keys() 1954 * 1955 * @returns { IterableIterator<string> } return a Map Iterator 1956 * @syscap SystemCapability.ArkUI.ArkUI.Full 1957 * @crossplatform 1958 * @form 1959 * @atomicservice 1960 * @since 11 1961 */ 1962 keys(): IterableIterator<string>; 1963 1964 /** 1965 * Returns number of properties in LocalStorage 1966 * same as Map.prototype.size() 1967 * 1968 * @returns { number } return number of properties 1969 * @syscap SystemCapability.ArkUI.ArkUI.Full 1970 * @form 1971 * @since 9 1972 */ 1973 /** 1974 * Returns number of properties in LocalStorage 1975 * same as Map.prototype.size() 1976 * 1977 * @returns { number } return number of properties 1978 * @syscap SystemCapability.ArkUI.ArkUI.Full 1979 * @crossplatform 1980 * @form 1981 * @since 10 1982 */ 1983 /** 1984 * Returns number of properties in LocalStorage 1985 * same as Map.prototype.size() 1986 * 1987 * @returns { number } return number of properties 1988 * @syscap SystemCapability.ArkUI.ArkUI.Full 1989 * @crossplatform 1990 * @form 1991 * @atomicservice 1992 * @since 11 1993 */ 1994 size(): number; 1995 1996 /** 1997 * Returns value of given property 1998 * return undefined if no property with this name 1999 * 2000 * @param { string } propName 2001 * @returns { T | undefined } property value if found or undefined 2002 * @syscap SystemCapability.ArkUI.ArkUI.Full 2003 * @form 2004 * @since 9 2005 */ 2006 /** 2007 * Returns value of given property 2008 * return undefined if no property with this name 2009 * 2010 * @param { string } propName 2011 * @returns { T | undefined } property value if found or undefined 2012 * @syscap SystemCapability.ArkUI.ArkUI.Full 2013 * @crossplatform 2014 * @form 2015 * @since 10 2016 */ 2017 /** 2018 * Returns value of given property 2019 * return undefined if no property with this name 2020 * 2021 * @param { string } propName 2022 * @returns { T | undefined } property value if found or undefined 2023 * @syscap SystemCapability.ArkUI.ArkUI.Full 2024 * @crossplatform 2025 * @form 2026 * @atomicservice 2027 * @since 11 2028 */ 2029 get<T>(propName: string): T | undefined; 2030 2031 /** 2032 * Set value of given property in LocalStorage 2033 * Method sets nothing and returns false if property with this name does not exist 2034 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2035 * 2036 * @param { string } propName 2037 * @param { T } newValue - must be of type T and must not be undefined or null 2038 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2039 * @syscap SystemCapability.ArkUI.ArkUI.Full 2040 * @form 2041 * @since 9 2042 */ 2043 /** 2044 * Set value of given property in LocalStorage 2045 * Method sets nothing and returns false if property with this name does not exist 2046 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2047 * 2048 * @param { string } propName 2049 * @param { T } newValue - must be of type T and must not be undefined or null 2050 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2051 * @syscap SystemCapability.ArkUI.ArkUI.Full 2052 * @crossplatform 2053 * @form 2054 * @since 10 2055 */ 2056 /** 2057 * Set value of given property in LocalStorage 2058 * Method sets nothing and returns false if property with this name does not exist 2059 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2060 * 2061 * @param { string } propName 2062 * @param { T } newValue - must be of type T and must not be undefined or null 2063 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2064 * @syscap SystemCapability.ArkUI.ArkUI.Full 2065 * @crossplatform 2066 * @form 2067 * @atomicservice 2068 * @since 11 2069 */ 2070 /** 2071 * Set value of given property in LocalStorage 2072 * Method sets nothing and returns false if property with this name does not exist in LocalStorage 2073 * newValue can be undefined or null from API 12. 2074 * 2075 * @param { string } propName 2076 * @param { T } newValue - must be of type T, can be undefined or null 2077 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2078 * @syscap SystemCapability.ArkUI.ArkUI.Full 2079 * @crossplatform 2080 * @form 2081 * @atomicservice 2082 * @since 12 2083 */ 2084 set<T>(propName: string, newValue: T): boolean; 2085 2086 /** 2087 * Set value of given property, if it exists, see set() . 2088 * Add property if no property with given name and initialize with given value. 2089 * Do nothing and return false if newValue is undefined or null 2090 * (undefined, null value is not allowed for state variables) 2091 * 2092 * @param { string } propName 2093 * @param { T } newValue - must be of type T and must not be undefined or null 2094 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2095 * @syscap SystemCapability.ArkUI.ArkUI.Full 2096 * @form 2097 * @since 9 2098 */ 2099 /** 2100 * Set value of given property, if it exists, see set() . 2101 * Add property if no property with given name and initialize with given value. 2102 * Do nothing and return false if newValue is undefined or null 2103 * (undefined, null value is not allowed for state variables) 2104 * 2105 * @param { string } propName 2106 * @param { T } newValue - must be of type T and must not be undefined or null 2107 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2108 * @syscap SystemCapability.ArkUI.ArkUI.Full 2109 * @crossplatform 2110 * @form 2111 * @since 10 2112 */ 2113 /** 2114 * Set value of given property, if it exists, see set() . 2115 * Add property if no property with given name and initialize with given value. 2116 * Do nothing and return false if newValue is undefined or null 2117 * (undefined, null value is not allowed for state variables) 2118 * 2119 * @param { string } propName 2120 * @param { T } newValue - must be of type T and must not be undefined or null 2121 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2122 * @syscap SystemCapability.ArkUI.ArkUI.Full 2123 * @crossplatform 2124 * @form 2125 * @atomicservice 2126 * @since 11 2127 */ 2128 /** 2129 * Set value of given property, if it exists, see set() . 2130 * Add property if no property with given name and initialize with given value. 2131 * newValue can be undefined or null from API 12 2132 * 2133 * @param { string } propName 2134 * @param { T } newValue - must be of type T, can be undefined or null 2135 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2136 * @syscap SystemCapability.ArkUI.ArkUI.Full 2137 * @crossplatform 2138 * @form 2139 * @atomicservice 2140 * @since 12 2141 */ 2142 setOrCreate<T>(propName: string, newValue: T): boolean; 2143 2144 /** 2145 * Create and return a two-way sync "(link") to named property 2146 * 2147 * @param { string } propName - name of source property in LocalStorage 2148 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2149 * return undefined if named property does not already exist in LocalStorage 2150 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2151 * @syscap SystemCapability.ArkUI.ArkUI.Full 2152 * @form 2153 * @since 9 2154 */ 2155 /** 2156 * Create and return a two-way sync "(link") to named property 2157 * 2158 * @param { string } propName - name of source property in LocalStorage 2159 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2160 * return undefined if named property does not already exist in LocalStorage 2161 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2162 * @syscap SystemCapability.ArkUI.ArkUI.Full 2163 * @crossplatform 2164 * @form 2165 * @since 10 2166 */ 2167 /** 2168 * Create and return a two-way sync "(link") to named property 2169 * 2170 * @param { string } propName - name of source property in LocalStorage 2171 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2172 * return undefined if named property does not already exist in LocalStorage 2173 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2174 * @syscap SystemCapability.ArkUI.ArkUI.Full 2175 * @crossplatform 2176 * @form 2177 * @atomicservice 2178 * @since 11 2179 */ 2180 link<T>(propName: string): SubscribedAbstractProperty<T>; 2181 2182 /** 2183 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2184 * 2185 * @param { string } propName - name of source property in LocalStorage 2186 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2187 * default value must be of type T, must not be undefined or null. 2188 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2189 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2190 * @syscap SystemCapability.ArkUI.ArkUI.Full 2191 * @form 2192 * @since 9 2193 */ 2194 /** 2195 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2196 * 2197 * @param { string } propName - name of source property in LocalStorage 2198 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2199 * default value must be of type T, must not be undefined or null. 2200 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2201 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2202 * @syscap SystemCapability.ArkUI.ArkUI.Full 2203 * @crossplatform 2204 * @form 2205 * @since 10 2206 */ 2207 /** 2208 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2209 * 2210 * @param { string } propName - name of source property in LocalStorage 2211 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2212 * default value must be of type T, must not be undefined or null. 2213 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2214 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2215 * @syscap SystemCapability.ArkUI.ArkUI.Full 2216 * @crossplatform 2217 * @form 2218 * @atomicservice 2219 * @since 11 2220 */ 2221 /** 2222 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2223 * 2224 * @param { string } propName - name of source property in LocalStorage 2225 * @param { T } defaultValue - value to be used for initializing new property in LocalStorage 2226 * default value must be of type T, can be undefined or null. 2227 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2228 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2229 * @syscap SystemCapability.ArkUI.ArkUI.Full 2230 * @crossplatform 2231 * @form 2232 * @atomicservice 2233 * @since 12 2234 */ 2235 setAndLink<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 2236 2237 /** 2238 * Create and return a one-way sync ('prop') to named property 2239 * 2240 * @param { string } propName - name of source property in LocalStorage 2241 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2242 * return undefined if named property does not already exist in LocalStorage 2243 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2244 * @syscap SystemCapability.ArkUI.ArkUI.Full 2245 * @form 2246 * @since 9 2247 */ 2248 /** 2249 * Create and return a one-way sync ('prop') to named property 2250 * 2251 * @param { string } propName - name of source property in LocalStorage 2252 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2253 * return undefined if named property does not already exist in LocalStorage 2254 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2255 * @syscap SystemCapability.ArkUI.ArkUI.Full 2256 * @crossplatform 2257 * @form 2258 * @since 10 2259 */ 2260 /** 2261 * Create and return a one-way sync ('prop') to named property 2262 * 2263 * @param { string } propName - name of source property in LocalStorage 2264 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2265 * return undefined if named property does not already exist in LocalStorage 2266 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2267 * @syscap SystemCapability.ArkUI.ArkUI.Full 2268 * @crossplatform 2269 * @form 2270 * @atomicservice 2271 * @since 11 2272 */ 2273 prop<S>(propName: string): SubscribedAbstractProperty<S>; 2274 2275 /** 2276 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2277 * 2278 * @param { string } propName - name of source property in LocalStorage 2279 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2280 * Default value must be of type T, must not be undefined or null. 2281 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2282 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2283 * @syscap SystemCapability.ArkUI.ArkUI.Full 2284 * @form 2285 * @since 9 2286 */ 2287 /** 2288 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2289 * 2290 * @param { string } propName - name of source property in LocalStorage 2291 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2292 * Default value must be of type T, must not be undefined or null. 2293 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2294 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2295 * @syscap SystemCapability.ArkUI.ArkUI.Full 2296 * @crossplatform 2297 * @form 2298 * @since 10 2299 */ 2300 /** 2301 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2302 * 2303 * @param { string } propName - name of source property in LocalStorage 2304 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2305 * Default value must be of type T, must not be undefined or null. 2306 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2307 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2308 * @syscap SystemCapability.ArkUI.ArkUI.Full 2309 * @crossplatform 2310 * @form 2311 * @atomicservice 2312 * @since 11 2313 */ 2314 /** 2315 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2316 * 2317 * @param { string } propName - name of source property in LocalStorage 2318 * @param { S } defaultValue - value to be used for initializing new property in LocalStorage. 2319 * Default value must be of type T, can be undefined or null. 2320 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2321 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2322 * @syscap SystemCapability.ArkUI.ArkUI.Full 2323 * @crossplatform 2324 * @form 2325 * @atomicservice 2326 * @since 12 2327 */ 2328 setAndProp<S>(propName: string, defaultValue: S): SubscribedAbstractProperty<S>; 2329 2330 /** 2331 * Delete property from StorageBase 2332 * Use with caution: 2333 * Before deleting a prop from LocalStorage all its subscribers need to 2334 * unsubscribe from the property. 2335 * This method fails and returns false if given property still has subscribers 2336 * Another reason for failing is unknown property. 2337 * Developer advise: 2338 * Subscribers are created with see link(), see prop() 2339 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2340 * That means as long as their is a @Component instance that uses such decorated variable 2341 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2342 * (and also should not!) be deleted from LocalStorage. 2343 * 2344 * @param { string } propName 2345 * @returns { boolean } false if method failed 2346 * @syscap SystemCapability.ArkUI.ArkUI.Full 2347 * @form 2348 * @since 9 2349 */ 2350 /** 2351 * Delete property from StorageBase 2352 * Use with caution: 2353 * Before deleting a prop from LocalStorage all its subscribers need to 2354 * unsubscribe from the property. 2355 * This method fails and returns false if given property still has subscribers 2356 * Another reason for failing is unknown property. 2357 * Developer advise: 2358 * Subscribers are created with see link(), see prop() 2359 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2360 * That means as long as their is a @Component instance that uses such decorated variable 2361 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2362 * (and also should not!) be deleted from LocalStorage. 2363 * 2364 * @param { string } propName 2365 * @returns { boolean } false if method failed 2366 * @syscap SystemCapability.ArkUI.ArkUI.Full 2367 * @crossplatform 2368 * @form 2369 * @since 10 2370 */ 2371 /** 2372 * Delete property from StorageBase 2373 * Use with caution: 2374 * Before deleting a prop from LocalStorage all its subscribers need to 2375 * unsubscribe from the property. 2376 * This method fails and returns false if given property still has subscribers 2377 * Another reason for failing is unknown property. 2378 * Developer advise: 2379 * Subscribers are created with see link(), see prop() 2380 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2381 * That means as long as their is a @Component instance that uses such decorated variable 2382 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2383 * (and also should not!) be deleted from LocalStorage. 2384 * 2385 * @param { string } propName 2386 * @returns { boolean } false if method failed 2387 * @syscap SystemCapability.ArkUI.ArkUI.Full 2388 * @crossplatform 2389 * @form 2390 * @atomicservice 2391 * @since 11 2392 */ 2393 delete(propName: string): boolean; 2394 2395 /** 2396 * Delete all properties from the LocalStorage instance 2397 * Precondition is that there are no subscribers. 2398 * method returns false and deletes no properties if there is any property 2399 * that still has subscribers 2400 * 2401 * @returns { boolean } 2402 * @syscap SystemCapability.ArkUI.ArkUI.Full 2403 * @form 2404 * @since 9 2405 */ 2406 /** 2407 * Delete all properties from the LocalStorage instance 2408 * Precondition is that there are no subscribers. 2409 * method returns false and deletes no properties if there is any property 2410 * that still has subscribers 2411 * 2412 * @returns { boolean } 2413 * @syscap SystemCapability.ArkUI.ArkUI.Full 2414 * @crossplatform 2415 * @form 2416 * @since 10 2417 */ 2418 /** 2419 * Delete all properties from the LocalStorage instance 2420 * Precondition is that there are no subscribers. 2421 * method returns false and deletes no properties if there is any property 2422 * that still has subscribers 2423 * 2424 * @returns { boolean } 2425 * @syscap SystemCapability.ArkUI.ArkUI.Full 2426 * @crossplatform 2427 * @form 2428 * @atomicservice 2429 * @since 11 2430 */ 2431 clear(): boolean; 2432} 2433