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 * @deprecated since 18 1863 * @useinstead ohos.arkui.UIContext.UIContext#getSharedLocalStorage 1864 */ 1865 static getShared(): LocalStorage; 1866 1867 /** 1868 * Obtain a handler or an alias to LocalStorage property with given name. 1869 * 1870 * @param { string } propName LocalStorage property name 1871 * @returns { AbstractProperty<T> | undefined } AbstractProperty object if property with given name exists 1872 * return undefined otherwise. 1873 * @syscap SystemCapability.ArkUI.ArkUI.Full 1874 * @crossplatform 1875 * @atomicservice 1876 * @since 12 1877 */ 1878 public ref<T>(propName: string): AbstractProperty<T> | undefined; 1879 1880 /** 1881 * Obtain a handler or an alias to LocalStorage property with given name. 1882 * 1883 * If property does not exist in LocalStorage, create it with given default value. 1884 * 1885 * @param { string } propName LocalStorage property name 1886 * @param { T } defaultValue If property does not exist in LocalStorage, 1887 * create it with given default value. 1888 * @returns { AbstractProperty<T> } AbstractProperty object 1889 * @syscap SystemCapability.ArkUI.ArkUI.Full 1890 * @crossplatform 1891 * @atomicservice 1892 * @since 12 1893 */ 1894 public setAndRef<T>(propName: string, defaultValue: T): AbstractProperty<T>; 1895 1896 /** 1897 * Check if LocalStorage has a property with given name 1898 * return true if property with given name exists 1899 * same as ES6 Map.prototype.has() 1900 * 1901 * @param { string } propName - searched property 1902 * @returns { boolean } true if property with such name exists in LocalStorage 1903 * @syscap SystemCapability.ArkUI.ArkUI.Full 1904 * @form 1905 * @since 9 1906 */ 1907 /** 1908 * Check if LocalStorage has a property with given name 1909 * return true if property with given name exists 1910 * same as ES6 Map.prototype.has() 1911 * 1912 * @param { string } propName - searched property 1913 * @returns { boolean } true if property with such name exists in LocalStorage 1914 * @syscap SystemCapability.ArkUI.ArkUI.Full 1915 * @crossplatform 1916 * @form 1917 * @since 10 1918 */ 1919 /** 1920 * Check if LocalStorage has a property with given name 1921 * return true if property with given name exists 1922 * same as ES6 Map.prototype.has() 1923 * 1924 * @param { string } propName - searched property 1925 * @returns { boolean } true if property with such name exists in LocalStorage 1926 * @syscap SystemCapability.ArkUI.ArkUI.Full 1927 * @crossplatform 1928 * @form 1929 * @atomicservice 1930 * @since 11 1931 */ 1932 has(propName: string): boolean; 1933 1934 /** 1935 * Provide names of all properties in LocalStorage 1936 * same as ES6 Map.prototype.keys() 1937 * 1938 * @returns { IterableIterator<string> } return a Map Iterator 1939 * @syscap SystemCapability.ArkUI.ArkUI.Full 1940 * @form 1941 * @since 9 1942 */ 1943 /** 1944 * Provide names of all properties in LocalStorage 1945 * same as ES6 Map.prototype.keys() 1946 * 1947 * @returns { IterableIterator<string> } return a Map Iterator 1948 * @syscap SystemCapability.ArkUI.ArkUI.Full 1949 * @crossplatform 1950 * @form 1951 * @since 10 1952 */ 1953 /** 1954 * Provide names of all properties in LocalStorage 1955 * same as ES6 Map.prototype.keys() 1956 * 1957 * @returns { IterableIterator<string> } return a Map Iterator 1958 * @syscap SystemCapability.ArkUI.ArkUI.Full 1959 * @crossplatform 1960 * @form 1961 * @atomicservice 1962 * @since 11 1963 */ 1964 keys(): IterableIterator<string>; 1965 1966 /** 1967 * Returns number of properties in LocalStorage 1968 * same as Map.prototype.size() 1969 * 1970 * @returns { number } return number of properties 1971 * @syscap SystemCapability.ArkUI.ArkUI.Full 1972 * @form 1973 * @since 9 1974 */ 1975 /** 1976 * Returns number of properties in LocalStorage 1977 * same as Map.prototype.size() 1978 * 1979 * @returns { number } return number of properties 1980 * @syscap SystemCapability.ArkUI.ArkUI.Full 1981 * @crossplatform 1982 * @form 1983 * @since 10 1984 */ 1985 /** 1986 * Returns number of properties in LocalStorage 1987 * same as Map.prototype.size() 1988 * 1989 * @returns { number } return number of properties 1990 * @syscap SystemCapability.ArkUI.ArkUI.Full 1991 * @crossplatform 1992 * @form 1993 * @atomicservice 1994 * @since 11 1995 */ 1996 size(): number; 1997 1998 /** 1999 * Returns value of given property 2000 * return undefined if no property with this name 2001 * 2002 * @param { string } propName 2003 * @returns { T | undefined } property value if found or undefined 2004 * @syscap SystemCapability.ArkUI.ArkUI.Full 2005 * @form 2006 * @since 9 2007 */ 2008 /** 2009 * Returns value of given property 2010 * return undefined if no property with this name 2011 * 2012 * @param { string } propName 2013 * @returns { T | undefined } property value if found or undefined 2014 * @syscap SystemCapability.ArkUI.ArkUI.Full 2015 * @crossplatform 2016 * @form 2017 * @since 10 2018 */ 2019 /** 2020 * Returns value of given property 2021 * return undefined if no property with this name 2022 * 2023 * @param { string } propName 2024 * @returns { T | undefined } property value if found or undefined 2025 * @syscap SystemCapability.ArkUI.ArkUI.Full 2026 * @crossplatform 2027 * @form 2028 * @atomicservice 2029 * @since 11 2030 */ 2031 get<T>(propName: string): T | undefined; 2032 2033 /** 2034 * Set value of given property in LocalStorage 2035 * Method sets nothing and returns false if property with this name does not exist 2036 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2037 * 2038 * @param { string } propName 2039 * @param { T } newValue - must be of type T and must not be undefined or null 2040 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2041 * @syscap SystemCapability.ArkUI.ArkUI.Full 2042 * @form 2043 * @since 9 2044 */ 2045 /** 2046 * Set value of given property in LocalStorage 2047 * Method sets nothing and returns false if property with this name does not exist 2048 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2049 * 2050 * @param { string } propName 2051 * @param { T } newValue - must be of type T and must not be undefined or null 2052 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2053 * @syscap SystemCapability.ArkUI.ArkUI.Full 2054 * @crossplatform 2055 * @form 2056 * @since 10 2057 */ 2058 /** 2059 * Set value of given property in LocalStorage 2060 * Method sets nothing and returns false if property with this name does not exist 2061 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2062 * 2063 * @param { string } propName 2064 * @param { T } newValue - must be of type T and must not be undefined or null 2065 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2066 * @syscap SystemCapability.ArkUI.ArkUI.Full 2067 * @crossplatform 2068 * @form 2069 * @atomicservice 2070 * @since 11 2071 */ 2072 /** 2073 * Set value of given property in LocalStorage 2074 * Method sets nothing and returns false if property with this name does not exist in LocalStorage 2075 * newValue can be undefined or null from API 12. 2076 * 2077 * @param { string } propName 2078 * @param { T } newValue - must be of type T, can be undefined or null 2079 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2080 * @syscap SystemCapability.ArkUI.ArkUI.Full 2081 * @crossplatform 2082 * @form 2083 * @atomicservice 2084 * @since 12 2085 */ 2086 set<T>(propName: string, newValue: T): boolean; 2087 2088 /** 2089 * Set value of given property, if it exists, see set() . 2090 * Add property if no property with given name and initialize with given value. 2091 * Do nothing and return false if newValue is undefined or null 2092 * (undefined, null value is not allowed for state variables) 2093 * 2094 * @param { string } propName 2095 * @param { T } newValue - must be of type T and must not be undefined or null 2096 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2097 * @syscap SystemCapability.ArkUI.ArkUI.Full 2098 * @form 2099 * @since 9 2100 */ 2101 /** 2102 * Set value of given property, if it exists, see set() . 2103 * Add property if no property with given name and initialize with given value. 2104 * Do nothing and return false if newValue is undefined or null 2105 * (undefined, null value is not allowed for state variables) 2106 * 2107 * @param { string } propName 2108 * @param { T } newValue - must be of type T and must not be undefined or null 2109 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2110 * @syscap SystemCapability.ArkUI.ArkUI.Full 2111 * @crossplatform 2112 * @form 2113 * @since 10 2114 */ 2115 /** 2116 * Set value of given property, if it exists, see set() . 2117 * Add property if no property with given name and initialize with given value. 2118 * Do nothing and return false if newValue is undefined or null 2119 * (undefined, null value is not allowed for state variables) 2120 * 2121 * @param { string } propName 2122 * @param { T } newValue - must be of type T and must not be undefined or null 2123 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2124 * @syscap SystemCapability.ArkUI.ArkUI.Full 2125 * @crossplatform 2126 * @form 2127 * @atomicservice 2128 * @since 11 2129 */ 2130 /** 2131 * Set value of given property, if it exists, see set() . 2132 * Add property if no property with given name and initialize with given value. 2133 * newValue can be undefined or null from API 12 2134 * 2135 * @param { string } propName 2136 * @param { T } newValue - must be of type T, can be undefined or null 2137 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2138 * @syscap SystemCapability.ArkUI.ArkUI.Full 2139 * @crossplatform 2140 * @form 2141 * @atomicservice 2142 * @since 12 2143 */ 2144 setOrCreate<T>(propName: string, newValue: T): boolean; 2145 2146 /** 2147 * Create and return a two-way sync "(link") to named property 2148 * 2149 * @param { string } propName - name of source property in LocalStorage 2150 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2151 * return undefined if named property does not already exist in LocalStorage 2152 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2153 * @syscap SystemCapability.ArkUI.ArkUI.Full 2154 * @form 2155 * @since 9 2156 */ 2157 /** 2158 * Create and return a two-way sync "(link") to named property 2159 * 2160 * @param { string } propName - name of source property in LocalStorage 2161 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2162 * return undefined if named property does not already exist in LocalStorage 2163 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2164 * @syscap SystemCapability.ArkUI.ArkUI.Full 2165 * @crossplatform 2166 * @form 2167 * @since 10 2168 */ 2169 /** 2170 * Create and return a two-way sync "(link") to named property 2171 * 2172 * @param { string } propName - name of source property in LocalStorage 2173 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2174 * return undefined if named property does not already exist in LocalStorage 2175 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2176 * @syscap SystemCapability.ArkUI.ArkUI.Full 2177 * @crossplatform 2178 * @form 2179 * @atomicservice 2180 * @since 11 2181 */ 2182 link<T>(propName: string): SubscribedAbstractProperty<T>; 2183 2184 /** 2185 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2186 * 2187 * @param { string } propName - name of source property in LocalStorage 2188 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2189 * default value must be of type T, must not be undefined or null. 2190 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2191 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2192 * @syscap SystemCapability.ArkUI.ArkUI.Full 2193 * @form 2194 * @since 9 2195 */ 2196 /** 2197 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2198 * 2199 * @param { string } propName - name of source property in LocalStorage 2200 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2201 * default value must be of type T, must not be undefined or null. 2202 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2203 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2204 * @syscap SystemCapability.ArkUI.ArkUI.Full 2205 * @crossplatform 2206 * @form 2207 * @since 10 2208 */ 2209 /** 2210 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2211 * 2212 * @param { string } propName - name of source property in LocalStorage 2213 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2214 * default value must be of type T, must not be undefined or null. 2215 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2216 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2217 * @syscap SystemCapability.ArkUI.ArkUI.Full 2218 * @crossplatform 2219 * @form 2220 * @atomicservice 2221 * @since 11 2222 */ 2223 /** 2224 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2225 * 2226 * @param { string } propName - name of source property in LocalStorage 2227 * @param { T } defaultValue - value to be used for initializing new property in LocalStorage 2228 * default value must be of type T, can be undefined or null. 2229 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2230 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2231 * @syscap SystemCapability.ArkUI.ArkUI.Full 2232 * @crossplatform 2233 * @form 2234 * @atomicservice 2235 * @since 12 2236 */ 2237 setAndLink<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 2238 2239 /** 2240 * Create and return a one-way sync ('prop') to named property 2241 * 2242 * @param { string } propName - name of source property in LocalStorage 2243 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2244 * return undefined if named property does not already exist in LocalStorage 2245 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2246 * @syscap SystemCapability.ArkUI.ArkUI.Full 2247 * @form 2248 * @since 9 2249 */ 2250 /** 2251 * Create and return a one-way sync ('prop') to named property 2252 * 2253 * @param { string } propName - name of source property in LocalStorage 2254 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2255 * return undefined if named property does not already exist in LocalStorage 2256 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2257 * @syscap SystemCapability.ArkUI.ArkUI.Full 2258 * @crossplatform 2259 * @form 2260 * @since 10 2261 */ 2262 /** 2263 * Create and return a one-way sync ('prop') to named property 2264 * 2265 * @param { string } propName - name of source property in LocalStorage 2266 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2267 * return undefined if named property does not already exist in LocalStorage 2268 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2269 * @syscap SystemCapability.ArkUI.ArkUI.Full 2270 * @crossplatform 2271 * @form 2272 * @atomicservice 2273 * @since 11 2274 */ 2275 prop<S>(propName: string): SubscribedAbstractProperty<S>; 2276 2277 /** 2278 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2279 * 2280 * @param { string } propName - name of source property in LocalStorage 2281 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2282 * Default value must be of type T, must not be undefined or null. 2283 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2284 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2285 * @syscap SystemCapability.ArkUI.ArkUI.Full 2286 * @form 2287 * @since 9 2288 */ 2289 /** 2290 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2291 * 2292 * @param { string } propName - name of source property in LocalStorage 2293 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2294 * Default value must be of type T, must not be undefined or null. 2295 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2296 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2297 * @syscap SystemCapability.ArkUI.ArkUI.Full 2298 * @crossplatform 2299 * @form 2300 * @since 10 2301 */ 2302 /** 2303 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2304 * 2305 * @param { string } propName - name of source property in LocalStorage 2306 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2307 * Default value must be of type T, must not be undefined or null. 2308 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2309 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2310 * @syscap SystemCapability.ArkUI.ArkUI.Full 2311 * @crossplatform 2312 * @form 2313 * @atomicservice 2314 * @since 11 2315 */ 2316 /** 2317 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2318 * 2319 * @param { string } propName - name of source property in LocalStorage 2320 * @param { S } defaultValue - value to be used for initializing new property in LocalStorage. 2321 * Default value must be of type T, can be undefined or null. 2322 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2323 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2324 * @syscap SystemCapability.ArkUI.ArkUI.Full 2325 * @crossplatform 2326 * @form 2327 * @atomicservice 2328 * @since 12 2329 */ 2330 setAndProp<S>(propName: string, defaultValue: S): SubscribedAbstractProperty<S>; 2331 2332 /** 2333 * Delete property from StorageBase 2334 * Use with caution: 2335 * Before deleting a prop from LocalStorage all its subscribers need to 2336 * unsubscribe from the property. 2337 * This method fails and returns false if given property still has subscribers 2338 * Another reason for failing is unknown property. 2339 * Developer advise: 2340 * Subscribers are created with see link(), see prop() 2341 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2342 * That means as long as their is a @Component instance that uses such decorated variable 2343 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2344 * (and also should not!) be deleted from LocalStorage. 2345 * 2346 * @param { string } propName 2347 * @returns { boolean } false if method failed 2348 * @syscap SystemCapability.ArkUI.ArkUI.Full 2349 * @form 2350 * @since 9 2351 */ 2352 /** 2353 * Delete property from StorageBase 2354 * Use with caution: 2355 * Before deleting a prop from LocalStorage all its subscribers need to 2356 * unsubscribe from the property. 2357 * This method fails and returns false if given property still has subscribers 2358 * Another reason for failing is unknown property. 2359 * Developer advise: 2360 * Subscribers are created with see link(), see prop() 2361 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2362 * That means as long as their is a @Component instance that uses such decorated variable 2363 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2364 * (and also should not!) be deleted from LocalStorage. 2365 * 2366 * @param { string } propName 2367 * @returns { boolean } false if method failed 2368 * @syscap SystemCapability.ArkUI.ArkUI.Full 2369 * @crossplatform 2370 * @form 2371 * @since 10 2372 */ 2373 /** 2374 * Delete property from StorageBase 2375 * Use with caution: 2376 * Before deleting a prop from LocalStorage all its subscribers need to 2377 * unsubscribe from the property. 2378 * This method fails and returns false if given property still has subscribers 2379 * Another reason for failing is unknown property. 2380 * Developer advise: 2381 * Subscribers are created with see link(), see prop() 2382 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2383 * That means as long as their is a @Component instance that uses such decorated variable 2384 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2385 * (and also should not!) be deleted from LocalStorage. 2386 * 2387 * @param { string } propName 2388 * @returns { boolean } false if method failed 2389 * @syscap SystemCapability.ArkUI.ArkUI.Full 2390 * @crossplatform 2391 * @form 2392 * @atomicservice 2393 * @since 11 2394 */ 2395 delete(propName: string): boolean; 2396 2397 /** 2398 * Delete all properties from the LocalStorage instance 2399 * Precondition is that there are no subscribers. 2400 * method returns false and deletes no properties if there is any property 2401 * that still has subscribers 2402 * 2403 * @returns { boolean } 2404 * @syscap SystemCapability.ArkUI.ArkUI.Full 2405 * @form 2406 * @since 9 2407 */ 2408 /** 2409 * Delete all properties from the LocalStorage instance 2410 * Precondition is that there are no subscribers. 2411 * method returns false and deletes no properties if there is any property 2412 * that still has subscribers 2413 * 2414 * @returns { boolean } 2415 * @syscap SystemCapability.ArkUI.ArkUI.Full 2416 * @crossplatform 2417 * @form 2418 * @since 10 2419 */ 2420 /** 2421 * Delete all properties from the LocalStorage instance 2422 * Precondition is that there are no subscribers. 2423 * method returns false and deletes no properties if there is any property 2424 * that still has subscribers 2425 * 2426 * @returns { boolean } 2427 * @syscap SystemCapability.ArkUI.ArkUI.Full 2428 * @crossplatform 2429 * @form 2430 * @atomicservice 2431 * @since 11 2432 */ 2433 clear(): boolean; 2434} 2435