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 * @interface ISinglePropertyChangeSubscriber 1232 * @syscap SystemCapability.ArkUI.ArkUI.Full 1233 * @systemapi 1234 * @since 7 1235 */ 1236interface ISinglePropertyChangeSubscriber<T> extends IPropertySubscriber { 1237 /** 1238 * Provides a single attribute change user interface. 1239 * 1240 * @param { T } newValue 1241 * @syscap SystemCapability.ArkUI.ArkUI.Full 1242 * @systemapi 1243 * @since 7 1244 */ 1245 hasChanged(newValue: T): void; 1246} 1247 1248/** 1249 * Defines the Subscribale base class. 1250 * 1251 * @syscap SystemCapability.ArkUI.ArkUI.Full 1252 * @systemapi 1253 * @since 7 1254 */ 1255declare abstract class SubscribaleAbstract { 1256 /** 1257 * Returns the ownership attribute set by the. 1258 * 1259 * @type { Set<number> } 1260 * @syscap SystemCapability.ArkUI.ArkUI.Full 1261 * @systemapi 1262 * @since 7 1263 */ 1264 private owningProperties_: Set<number>; 1265 1266 /** 1267 * Constructor. 1268 * 1269 * @syscap SystemCapability.ArkUI.ArkUI.Full 1270 * @systemapi 1271 * @since 7 1272 */ 1273 constructor(); 1274 1275 /** 1276 * Called when the notification property has changed. 1277 * 1278 * @param { string } propName 1279 * @param { any } newValue 1280 * @syscap SystemCapability.ArkUI.ArkUI.Full 1281 * @systemapi 1282 * @since 7 1283 */ 1284 protected notifyPropertyHasChanged(propName: string, newValue: any): void; 1285 1286 /** 1287 * Called when adding an already owned property. 1288 * 1289 * @param { IPropertySubscriber } subscriber 1290 * @syscap SystemCapability.ArkUI.ArkUI.Full 1291 * @systemapi 1292 * @since 7 1293 */ 1294 public addOwningProperty(subscriber: IPropertySubscriber): void; 1295 1296 /** 1297 * Called when an already owned property is deleted. 1298 * 1299 * @param { IPropertySubscriber } property 1300 * @syscap SystemCapability.ArkUI.ArkUI.Full 1301 * @systemapi 1302 * @since 7 1303 */ 1304 public removeOwningProperty(property: IPropertySubscriber): void; 1305 1306 /** 1307 * Called when an already owned property is deleted by ID 1308 * 1309 * @param { number } subscriberId 1310 * @syscap SystemCapability.ArkUI.ArkUI.Full 1311 * @systemapi 1312 * @since 7 1313 */ 1314 public removeOwningPropertyById(subscriberId: number): void; 1315} 1316 1317/** 1318 * EnvProps object 1319 * 1320 * @interface EnvPropsOptions 1321 * @syscap SystemCapability.ArkUI.ArkUI.Full 1322 * @crossplatform 1323 * @since 10 1324 */ 1325/** 1326 * EnvProps object 1327 * 1328 * @interface EnvPropsOptions 1329 * @syscap SystemCapability.ArkUI.ArkUI.Full 1330 * @crossplatform 1331 * @atomicservice 1332 * @since 11 1333 */ 1334declare interface EnvPropsOptions { 1335 /** 1336 * Property name of Environment variable 1337 * 1338 * @type { string } 1339 * @syscap SystemCapability.ArkUI.ArkUI.Full 1340 * @crossplatform 1341 * @since 10 1342 */ 1343 /** 1344 * Property name of Environment variable 1345 * 1346 * @type { string } 1347 * @syscap SystemCapability.ArkUI.ArkUI.Full 1348 * @crossplatform 1349 * @atomicservice 1350 * @since 11 1351 */ 1352 key: string; 1353 1354 /** 1355 * DefaultValue is the default value if cannot get the environment property value 1356 * 1357 * @type { number | string | boolean } 1358 * @syscap SystemCapability.ArkUI.ArkUI.Full 1359 * @crossplatform 1360 * @since 10 1361 */ 1362 /** 1363 * DefaultValue is the default value if cannot get the environment property value 1364 * 1365 * @type { number | string | boolean } 1366 * @syscap SystemCapability.ArkUI.ArkUI.Full 1367 * @crossplatform 1368 * @atomicservice 1369 * @since 11 1370 */ 1371 defaultValue: number | string | boolean; 1372} 1373 1374/** 1375 * Defines the Environment interface. 1376 * 1377 * @syscap SystemCapability.ArkUI.ArkUI.Full 1378 * @since 7 1379 */ 1380/** 1381 * Defines the Environment interface. 1382 * 1383 * @syscap SystemCapability.ArkUI.ArkUI.Full 1384 * @crossplatform 1385 * @since 10 1386 */ 1387/** 1388 * Defines the Environment interface. 1389 * 1390 * @syscap SystemCapability.ArkUI.ArkUI.Full 1391 * @crossplatform 1392 * @atomicservice 1393 * @since 11 1394 */ 1395declare class Environment { 1396 /** 1397 * Constructor. 1398 * 1399 * @syscap SystemCapability.ArkUI.ArkUI.Full 1400 * @systemapi 1401 * @since 7 1402 */ 1403 constructor(); 1404 1405 /** 1406 * Called when a property value is added to Environment. 1407 * 1408 * @param { string } key 1409 * @param { S } value 1410 * @returns { boolean } 1411 * @syscap SystemCapability.ArkUI.ArkUI.Full 1412 * @since 7 1413 * @deprecated since 10 1414 * @useinstead Environment#envProp 1415 */ 1416 static EnvProp<S>(key: string, value: S): boolean; 1417 1418 /** 1419 * Creates a new property in AppStorage. The UI framework implementation takes care of updating 1420 * its value whenever the named device environment property changes. Recommended use is at app startup. 1421 * The function call fails and returns false if a property with given name exists in AppStorage already. 1422 * It is wrong API use to access a property with given name in AppStorage before calling Environment.envProp. 1423 * 1424 * @param { string } key - environment property 1425 * @param { S } value - is the default value if cannot get the environment property value 1426 * @returns { boolean } false if method failed 1427 * @syscap SystemCapability.ArkUI.ArkUI.Full 1428 * @crossplatform 1429 * @since 10 1430 */ 1431 /** 1432 * Creates a new property in AppStorage. The UI framework implementation takes care of updating 1433 * its value whenever the named device environment property changes. Recommended use is at app startup. 1434 * The function call fails and returns false if a property with given name exists in AppStorage already. 1435 * It is wrong API use to access a property with given name in AppStorage before calling Environment.envProp. 1436 * 1437 * @param { string } key - environment property 1438 * @param { S } value - is the default value if cannot get the environment property value 1439 * @returns { boolean } false if method failed 1440 * @syscap SystemCapability.ArkUI.ArkUI.Full 1441 * @crossplatform 1442 * @atomicservice 1443 * @since 11 1444 */ 1445 static envProp<S>(key: string, value: S): boolean; 1446 1447 /** 1448 * Called when multiple property values are added to Environment. 1449 * 1450 * @param { {key: string;defaultValue: any;}[] } props 1451 * @syscap SystemCapability.ArkUI.ArkUI.Full 1452 * @since 7 1453 * @deprecated since 10 1454 * @useinstead Environment#envProps 1455 */ 1456 static EnvProps( 1457 props: { 1458 key: string; 1459 defaultValue: any; 1460 }[], 1461 ): void; 1462 1463 /** 1464 * Called when multiple property values are added to Environment. 1465 * 1466 * @param { EnvPropsOptions[] } props 1467 * @syscap SystemCapability.ArkUI.ArkUI.Full 1468 * @crossplatform 1469 * @since 10 1470 */ 1471 /** 1472 * Called when multiple property values are added to Environment. 1473 * 1474 * @param { EnvPropsOptions[] } props 1475 * @syscap SystemCapability.ArkUI.ArkUI.Full 1476 * @crossplatform 1477 * @atomicservice 1478 * @since 11 1479 */ 1480 static envProps(props: EnvPropsOptions[]): void; 1481 1482 /** 1483 * returns an Array<string> of all environment property keys 1484 * 1485 * @returns { Array<string> } 1486 * @syscap SystemCapability.ArkUI.ArkUI.Full 1487 * @since 7 1488 * @deprecated since 10 1489 * @useinstead Environment#keys 1490 */ 1491 static Keys(): Array<string>; 1492 1493 /** 1494 * returns an Array<string> of all environment property keys 1495 * 1496 * @returns { Array<string> } all environment property keys 1497 * @syscap SystemCapability.ArkUI.ArkUI.Full 1498 * @crossplatform 1499 * @since 10 1500 */ 1501 /** 1502 * returns an Array<string> of all environment property keys 1503 * 1504 * @returns { Array<string> } all environment property keys 1505 * @syscap SystemCapability.ArkUI.ArkUI.Full 1506 * @crossplatform 1507 * @atomicservice 1508 * @since 11 1509 */ 1510 static keys(): Array<string>; 1511} 1512 1513/** 1514 * PersistProps object 1515 * 1516 * @interface PersistPropsOptions 1517 * @syscap SystemCapability.ArkUI.ArkUI.Full 1518 * @crossplatform 1519 * @since 10 1520 */ 1521/** 1522 * PersistProps object 1523 * 1524 * @interface PersistPropsOptions 1525 * @syscap SystemCapability.ArkUI.ArkUI.Full 1526 * @crossplatform 1527 * @atomicservice 1528 * @since 11 1529 */ 1530declare interface PersistPropsOptions { 1531 /** 1532 * Property name 1533 * 1534 * @type { string } 1535 * @syscap SystemCapability.ArkUI.ArkUI.Full 1536 * @crossplatform 1537 * @since 10 1538 */ 1539 /** 1540 * Property name 1541 * 1542 * @type { string } 1543 * @syscap SystemCapability.ArkUI.ArkUI.Full 1544 * @crossplatform 1545 * @atomicservice 1546 * @since 11 1547 */ 1548 key: string; 1549 1550 /** 1551 * If AppStorage does not include this property it will be initialized with this value 1552 * 1553 * @type { number | string | boolean | Object } 1554 * @syscap SystemCapability.ArkUI.ArkUI.Full 1555 * @crossplatform 1556 * @since 10 1557 */ 1558 /** 1559 * If AppStorage does not include this property it will be initialized with this value 1560 * 1561 * @type { number | string | boolean | Object } 1562 * @syscap SystemCapability.ArkUI.ArkUI.Full 1563 * @crossplatform 1564 * @atomicservice 1565 * @since 11 1566 */ 1567 defaultValue: number | string | boolean | Object; 1568} 1569 1570/** 1571 * Defines the PersistentStorage interface. 1572 * 1573 * @syscap SystemCapability.ArkUI.ArkUI.Full 1574 * @since 7 1575 */ 1576/** 1577 * Defines the PersistentStorage interface. 1578 * 1579 * @syscap SystemCapability.ArkUI.ArkUI.Full 1580 * @crossplatform 1581 * @since 10 1582 */ 1583/** 1584 * Defines the PersistentStorage interface. 1585 * 1586 * @syscap SystemCapability.ArkUI.ArkUI.Full 1587 * @crossplatform 1588 * @atomicservice 1589 * @since 11 1590 */ 1591declare class PersistentStorage { 1592 /** 1593 * Constructor parameters. 1594 * 1595 * @param { AppStorage } appStorage 1596 * @param { Storage } storage 1597 * @syscap SystemCapability.ArkUI.ArkUI.Full 1598 * @systemapi 1599 * @since 7 1600 */ 1601 constructor(appStorage: AppStorage, storage: Storage); 1602 1603 /** 1604 * Called when a persistence property is stored. 1605 * 1606 * @param { string } key 1607 * @param { T } defaultValue 1608 * @syscap SystemCapability.ArkUI.ArkUI.Full 1609 * @since 7 1610 * @deprecated since 10 1611 * @useinstead PersistentStorage#persistProp 1612 */ 1613 static PersistProp<T>(key: string, defaultValue: T): void; 1614 1615 /** 1616 * Add property 'key' to AppStorage properties whose current value will be 1617 * persistent. 1618 * If AppStorage does not include this property it will be added and initializes 1619 * with given value 1620 * 1621 * @param { string } key - property name 1622 * @param { T } defaultValue - If AppStorage does not include this property it will be initialized with this value 1623 * @syscap SystemCapability.ArkUI.ArkUI.Full 1624 * @crossplatform 1625 * @since 10 1626 */ 1627 /** 1628 * Add property 'key' to AppStorage properties whose current value will be 1629 * persistent. 1630 * If AppStorage does not include this property it will be added and initializes 1631 * with given value 1632 * 1633 * @param { string } key - property name 1634 * @param { T } defaultValue - If AppStorage does not include this property it will be initialized with this value 1635 * @syscap SystemCapability.ArkUI.ArkUI.Full 1636 * @crossplatform 1637 * @atomicservice 1638 * @since 11 1639 */ 1640 static persistProp<T>(key: string, defaultValue: T): void; 1641 1642 /** 1643 * Called when a property is deleted. 1644 * 1645 * @param { string } key 1646 * @syscap SystemCapability.ArkUI.ArkUI.Full 1647 * @since 7 1648 * @deprecated since 10 1649 * @useinstead PersistentStorage#deleteProp 1650 */ 1651 static DeleteProp(key: string): void; 1652 1653 /** 1654 * Reverse of @see persistProp 1655 * 1656 * @param { string } key - no longer persist the property named key 1657 * @syscap SystemCapability.ArkUI.ArkUI.Full 1658 * @crossplatform 1659 * @since 10 1660 */ 1661 /** 1662 * Reverse of @see persistProp 1663 * 1664 * @param { string } key - no longer persist the property named key 1665 * @syscap SystemCapability.ArkUI.ArkUI.Full 1666 * @crossplatform 1667 * @atomicservice 1668 * @since 11 1669 */ 1670 static deleteProp(key: string): void; 1671 1672 /** 1673 * Called when multiple persistence properties are stored. 1674 * 1675 * @param { {key: string;defaultValue: any;}[] } properties 1676 * @syscap SystemCapability.ArkUI.ArkUI.Full 1677 * @since 7 1678 * @deprecated since 10 1679 * @useinstead PersistentStorage#PersistProps 1680 */ 1681 static PersistProps( 1682 properties: { 1683 key: string; 1684 defaultValue: any; 1685 }[], 1686 ): void; 1687 1688 /** 1689 * Persist given AppStorage properties with given names. 1690 * If a property does not exist in AppStorage, add it and initialize it with given value 1691 * works as @see persistProp for multiple properties. 1692 * 1693 * @param { PersistPropsOptions[] } props 1694 * @syscap SystemCapability.ArkUI.ArkUI.Full 1695 * @crossplatform 1696 * @since 10 1697 */ 1698 /** 1699 * Persist given AppStorage properties with given names. 1700 * If a property does not exist in AppStorage, add it and initialize it with given value 1701 * works as @see persistProp for multiple properties. 1702 * 1703 * @param { PersistPropsOptions[] } props 1704 * @syscap SystemCapability.ArkUI.ArkUI.Full 1705 * @crossplatform 1706 * @atomicservice 1707 * @since 11 1708 */ 1709 static persistProps(props: PersistPropsOptions[]): void; 1710 1711 /** 1712 * Inform persisted AppStorage property names 1713 * returns an Array<string> of persisted AppStorage property names 1714 * 1715 * @returns { Array<string> } 1716 * @syscap SystemCapability.ArkUI.ArkUI.Full 1717 * @since 7 1718 * @deprecated since 10 1719 * @useinstead PersistentStorage#keys 1720 */ 1721 static Keys(): Array<string>; 1722 1723 /** 1724 * Inform persisted AppStorage property names 1725 * returns an Array<string> of persisted AppStorage property names 1726 * 1727 * @returns { Array<string> } array of AppStorage keys 1728 * @syscap SystemCapability.ArkUI.ArkUI.Full 1729 * @crossplatform 1730 * @since 10 1731 */ 1732 /** 1733 * Inform persisted AppStorage property names 1734 * 1735 * @returns { Array<string> } array of AppStorage keys 1736 * @syscap SystemCapability.ArkUI.ArkUI.Full 1737 * @crossplatform 1738 * @atomicservice 1739 * @since 11 1740 */ 1741 static keys(): Array<string>; 1742} 1743 1744/** 1745 * Used for ide. 1746 * 1747 * @syscap SystemCapability.ArkUI.ArkUI.Full 1748 * @systemapi 1749 * @since 7 1750 */ 1751declare const appStorage: AppStorage; 1752 1753/** 1754 * LocalStorage 1755 * Class implements a Map of ObservableObjectBase UI state variables. 1756 * Instances can be created to manage UI state within a limited "local" 1757 * access, and life cycle as defined by the app. 1758 * AppStorage singleton is sub-class of LocalStorage for 1759 * UI state of app-wide access and same life cycle as the app. 1760 * 1761 * @syscap SystemCapability.ArkUI.ArkUI.Full 1762 * @form 1763 * @since 9 1764 */ 1765/** 1766 * LocalStorage 1767 * Class implements a Map of ObservableObjectBase UI state variables. 1768 * Instances can be created to manage UI state within a limited "local" 1769 * access, and life cycle as defined by the app. 1770 * AppStorage singleton is sub-class of LocalStorage for 1771 * UI state of app-wide access and same life cycle as the app. 1772 * 1773 * @syscap SystemCapability.ArkUI.ArkUI.Full 1774 * @crossplatform 1775 * @form 1776 * @since 10 1777 */ 1778/** 1779 * LocalStorage 1780 * Class implements a Map of ObservableObjectBase UI state variables. 1781 * Instances can be created to manage UI state within a limited "local" 1782 * access, and life cycle as defined by the app. 1783 * AppStorage singleton is sub-class of LocalStorage for 1784 * UI state of app-wide access and same life cycle as the app. 1785 * 1786 * @syscap SystemCapability.ArkUI.ArkUI.Full 1787 * @crossplatform 1788 * @form 1789 * @atomicservice 1790 * @since 11 1791 */ 1792declare class LocalStorage { 1793 /** 1794 * Construct new instance of LocalStorage 1795 * initialize with all properties and their values that Object.keys(params) returns 1796 * Property values must not be undefined. 1797 * 1798 * @param { Object } [initializingProperties] - Object containing keys and values. see set() for valid values 1799 * @syscap SystemCapability.ArkUI.ArkUI.Full 1800 * @form 1801 * @since 9 1802 */ 1803 /** 1804 * Construct new instance of LocalStorage 1805 * initialize with all properties and their values that Object.keys(params) returns 1806 * Property values must not be undefined. 1807 * 1808 * @param { Object } [initializingProperties] - Object containing keys and values. see set() for valid values 1809 * @syscap SystemCapability.ArkUI.ArkUI.Full 1810 * @crossplatform 1811 * @form 1812 * @since 10 1813 */ 1814 /** 1815 * Construct new instance of LocalStorage 1816 * initialize with all properties and their values that Object.keys(params) returns 1817 * Property values must not be undefined. 1818 * 1819 * @param { Object } [initializingProperties] - Object containing keys and values. see set() for valid values 1820 * @syscap SystemCapability.ArkUI.ArkUI.Full 1821 * @crossplatform 1822 * @form 1823 * @atomicservice 1824 * @since 11 1825 */ 1826 constructor(initializingProperties?: Object); 1827 1828 /** 1829 * Get current LocalStorage shared from stage. 1830 * 1831 * @returns { LocalStorage } 1832 * @syscap SystemCapability.ArkUI.ArkUI.Full 1833 * @StageModelOnly 1834 * @form 1835 * @since 9 1836 * @deprecated since 10 1837 * @useinstead LocalStorage#getShared 1838 */ 1839 static GetShared(): LocalStorage; 1840 1841 /** 1842 * Get current LocalStorage shared from stage. 1843 * 1844 * @returns { LocalStorage } instance 1845 * @syscap SystemCapability.ArkUI.ArkUI.Full 1846 * @StageModelOnly 1847 * @crossplatform 1848 * @form 1849 * @since 10 1850 */ 1851 /** 1852 * Get current LocalStorage shared from stage. 1853 * 1854 * @returns { LocalStorage } instance 1855 * @syscap SystemCapability.ArkUI.ArkUI.Full 1856 * @StageModelOnly 1857 * @crossplatform 1858 * @form 1859 * @atomicservice 1860 * @since 11 1861 */ 1862 static getShared(): LocalStorage; 1863 1864 /** 1865 * Obtain a handler or an alias to LocalStorage property with given name. 1866 * 1867 * @param { string } propName LocalStorage property name 1868 * @returns { AbstractProperty<T> | undefined } AbstractProperty object if property with given name exists 1869 * return undefined otherwise. 1870 * @syscap SystemCapability.ArkUI.ArkUI.Full 1871 * @crossplatform 1872 * @atomicservice 1873 * @since 12 1874 */ 1875 public ref<T>(propName: string): AbstractProperty<T> | undefined; 1876 1877 /** 1878 * Obtain a handler or an alias to LocalStorage property with given name. 1879 * 1880 * If property does not exist in LocalStorage, create it with given default value. 1881 * 1882 * @param { string } propName LocalStorage property name 1883 * @param { T } defaultValue If property does not exist in LocalStorage, 1884 * create it with given default value. 1885 * @returns { AbstractProperty<T> } AbstractProperty object 1886 * @syscap SystemCapability.ArkUI.ArkUI.Full 1887 * @crossplatform 1888 * @atomicservice 1889 * @since 12 1890 */ 1891 public setAndRef<T>(propName: string, defaultValue: T): AbstractProperty<T>; 1892 1893 /** 1894 * Check if LocalStorage has a property with given name 1895 * return true if property with given name exists 1896 * same as ES6 Map.prototype.has() 1897 * 1898 * @param { string } propName - searched property 1899 * @returns { boolean } true if property with such name exists in LocalStorage 1900 * @syscap SystemCapability.ArkUI.ArkUI.Full 1901 * @form 1902 * @since 9 1903 */ 1904 /** 1905 * Check if LocalStorage has a property with given name 1906 * return true if property with given name exists 1907 * same as ES6 Map.prototype.has() 1908 * 1909 * @param { string } propName - searched property 1910 * @returns { boolean } true if property with such name exists in LocalStorage 1911 * @syscap SystemCapability.ArkUI.ArkUI.Full 1912 * @crossplatform 1913 * @form 1914 * @since 10 1915 */ 1916 /** 1917 * Check if LocalStorage has a property with given name 1918 * return true if property with given name exists 1919 * same as ES6 Map.prototype.has() 1920 * 1921 * @param { string } propName - searched property 1922 * @returns { boolean } true if property with such name exists in LocalStorage 1923 * @syscap SystemCapability.ArkUI.ArkUI.Full 1924 * @crossplatform 1925 * @form 1926 * @atomicservice 1927 * @since 11 1928 */ 1929 has(propName: string): boolean; 1930 1931 /** 1932 * Provide names of all properties in LocalStorage 1933 * same as ES6 Map.prototype.keys() 1934 * 1935 * @returns { IterableIterator<string> } return a Map Iterator 1936 * @syscap SystemCapability.ArkUI.ArkUI.Full 1937 * @form 1938 * @since 9 1939 */ 1940 /** 1941 * Provide names of all properties in LocalStorage 1942 * same as ES6 Map.prototype.keys() 1943 * 1944 * @returns { IterableIterator<string> } return a Map Iterator 1945 * @syscap SystemCapability.ArkUI.ArkUI.Full 1946 * @crossplatform 1947 * @form 1948 * @since 10 1949 */ 1950 /** 1951 * Provide names of all properties in LocalStorage 1952 * same as ES6 Map.prototype.keys() 1953 * 1954 * @returns { IterableIterator<string> } return a Map Iterator 1955 * @syscap SystemCapability.ArkUI.ArkUI.Full 1956 * @crossplatform 1957 * @form 1958 * @atomicservice 1959 * @since 11 1960 */ 1961 keys(): IterableIterator<string>; 1962 1963 /** 1964 * Returns number of properties in LocalStorage 1965 * same as Map.prototype.size() 1966 * 1967 * @returns { number } return number of properties 1968 * @syscap SystemCapability.ArkUI.ArkUI.Full 1969 * @form 1970 * @since 9 1971 */ 1972 /** 1973 * Returns number of properties in LocalStorage 1974 * same as Map.prototype.size() 1975 * 1976 * @returns { number } return number of properties 1977 * @syscap SystemCapability.ArkUI.ArkUI.Full 1978 * @crossplatform 1979 * @form 1980 * @since 10 1981 */ 1982 /** 1983 * Returns number of properties in LocalStorage 1984 * same as Map.prototype.size() 1985 * 1986 * @returns { number } return number of properties 1987 * @syscap SystemCapability.ArkUI.ArkUI.Full 1988 * @crossplatform 1989 * @form 1990 * @atomicservice 1991 * @since 11 1992 */ 1993 size(): number; 1994 1995 /** 1996 * Returns value of given property 1997 * return undefined if no property with this name 1998 * 1999 * @param { string } propName 2000 * @returns { T | undefined } property value if found or undefined 2001 * @syscap SystemCapability.ArkUI.ArkUI.Full 2002 * @form 2003 * @since 9 2004 */ 2005 /** 2006 * Returns value of given property 2007 * return undefined if no property with this name 2008 * 2009 * @param { string } propName 2010 * @returns { T | undefined } property value if found or undefined 2011 * @syscap SystemCapability.ArkUI.ArkUI.Full 2012 * @crossplatform 2013 * @form 2014 * @since 10 2015 */ 2016 /** 2017 * Returns value of given property 2018 * return undefined if no property with this name 2019 * 2020 * @param { string } propName 2021 * @returns { T | undefined } property value if found or undefined 2022 * @syscap SystemCapability.ArkUI.ArkUI.Full 2023 * @crossplatform 2024 * @form 2025 * @atomicservice 2026 * @since 11 2027 */ 2028 get<T>(propName: string): T | undefined; 2029 2030 /** 2031 * Set value of given property in LocalStorage 2032 * Method sets nothing and returns false if property with this name does not exist 2033 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2034 * 2035 * @param { string } propName 2036 * @param { T } newValue - must be of type T and must not be undefined or null 2037 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2038 * @syscap SystemCapability.ArkUI.ArkUI.Full 2039 * @form 2040 * @since 9 2041 */ 2042 /** 2043 * Set value of given property in LocalStorage 2044 * Method sets nothing and returns false if property with this name does not exist 2045 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2046 * 2047 * @param { string } propName 2048 * @param { T } newValue - must be of type T and must not be undefined or null 2049 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2050 * @syscap SystemCapability.ArkUI.ArkUI.Full 2051 * @crossplatform 2052 * @form 2053 * @since 10 2054 */ 2055 /** 2056 * Set value of given property in LocalStorage 2057 * Method sets nothing and returns false if property with this name does not exist 2058 * or if newValue is `undefined` or `null` (`undefined`, `null` value are not allowed for state variables). 2059 * 2060 * @param { string } propName 2061 * @param { T } newValue - must be of type T and must not be undefined or null 2062 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2063 * @syscap SystemCapability.ArkUI.ArkUI.Full 2064 * @crossplatform 2065 * @form 2066 * @atomicservice 2067 * @since 11 2068 */ 2069 /** 2070 * Set value of given property in LocalStorage 2071 * Method sets nothing and returns false if property with this name does not exist in LocalStorage 2072 * newValue can be undefined or null from API 12. 2073 * 2074 * @param { string } propName 2075 * @param { T } newValue - must be of type T, can be undefined or null 2076 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2077 * @syscap SystemCapability.ArkUI.ArkUI.Full 2078 * @crossplatform 2079 * @form 2080 * @atomicservice 2081 * @since 12 2082 */ 2083 set<T>(propName: string, newValue: T): boolean; 2084 2085 /** 2086 * Set value of given property, if it exists, see set() . 2087 * Add property if no property with given name and initialize with given value. 2088 * Do nothing and return false if newValue is undefined or null 2089 * (undefined, null value is not allowed for state variables) 2090 * 2091 * @param { string } propName 2092 * @param { T } newValue - must be of type T and must not be undefined or null 2093 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2094 * @syscap SystemCapability.ArkUI.ArkUI.Full 2095 * @form 2096 * @since 9 2097 */ 2098 /** 2099 * Set value of given property, if it exists, see set() . 2100 * Add property if no property with given name and initialize with given value. 2101 * Do nothing and return false if newValue is undefined or null 2102 * (undefined, null value is not allowed for state variables) 2103 * 2104 * @param { string } propName 2105 * @param { T } newValue - must be of type T and must not be undefined or null 2106 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2107 * @syscap SystemCapability.ArkUI.ArkUI.Full 2108 * @crossplatform 2109 * @form 2110 * @since 10 2111 */ 2112 /** 2113 * Set value of given property, if it exists, see set() . 2114 * Add property if no property with given name and initialize with given value. 2115 * Do nothing and return false if newValue is undefined or null 2116 * (undefined, null value is not allowed for state variables) 2117 * 2118 * @param { string } propName 2119 * @param { T } newValue - must be of type T and must not be undefined or null 2120 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2121 * @syscap SystemCapability.ArkUI.ArkUI.Full 2122 * @crossplatform 2123 * @form 2124 * @atomicservice 2125 * @since 11 2126 */ 2127 /** 2128 * Set value of given property, if it exists, see set() . 2129 * Add property if no property with given name and initialize with given value. 2130 * newValue can be undefined or null from API 12 2131 * 2132 * @param { string } propName 2133 * @param { T } newValue - must be of type T, can be undefined or null 2134 * @returns { boolean } true on success, i.e. when above conditions are satisfied, otherwise false 2135 * @syscap SystemCapability.ArkUI.ArkUI.Full 2136 * @crossplatform 2137 * @form 2138 * @atomicservice 2139 * @since 12 2140 */ 2141 setOrCreate<T>(propName: string, newValue: T): boolean; 2142 2143 /** 2144 * Create and return a two-way sync "(link") to named property 2145 * 2146 * @param { string } propName - name of source property in LocalStorage 2147 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2148 * return undefined if named property does not already exist in LocalStorage 2149 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2150 * @syscap SystemCapability.ArkUI.ArkUI.Full 2151 * @form 2152 * @since 9 2153 */ 2154 /** 2155 * Create and return a two-way sync "(link") to named property 2156 * 2157 * @param { string } propName - name of source property in LocalStorage 2158 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2159 * return undefined if named property does not already exist in LocalStorage 2160 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2161 * @syscap SystemCapability.ArkUI.ArkUI.Full 2162 * @crossplatform 2163 * @form 2164 * @since 10 2165 */ 2166 /** 2167 * Create and return a two-way sync "(link") to named property 2168 * 2169 * @param { string } propName - name of source property in LocalStorage 2170 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2171 * return undefined if named property does not already exist in LocalStorage 2172 * Apps can use SDK functions of base class SubscribedPropertyAbstract<T> 2173 * @syscap SystemCapability.ArkUI.ArkUI.Full 2174 * @crossplatform 2175 * @form 2176 * @atomicservice 2177 * @since 11 2178 */ 2179 link<T>(propName: string): SubscribedAbstractProperty<T>; 2180 2181 /** 2182 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2183 * 2184 * @param { string } propName - name of source property in LocalStorage 2185 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2186 * default value must be of type T, must not be undefined or null. 2187 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2188 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2189 * @syscap SystemCapability.ArkUI.ArkUI.Full 2190 * @form 2191 * @since 9 2192 */ 2193 /** 2194 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2195 * 2196 * @param { string } propName - name of source property in LocalStorage 2197 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2198 * default value must be of type T, must not be undefined or null. 2199 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2200 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2201 * @syscap SystemCapability.ArkUI.ArkUI.Full 2202 * @crossplatform 2203 * @form 2204 * @since 10 2205 */ 2206 /** 2207 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2208 * 2209 * @param { string } propName - name of source property in LocalStorage 2210 * @param { T } defaultValue - value to be used for initializing if new creating new property in LocalStorage 2211 * default value must be of type T, must not be undefined or null. 2212 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2213 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2214 * @syscap SystemCapability.ArkUI.ArkUI.Full 2215 * @crossplatform 2216 * @form 2217 * @atomicservice 2218 * @since 11 2219 */ 2220 /** 2221 * Like see link(), but will create and initialize a new source property in LocalStorage if missing 2222 * 2223 * @param { string } propName - name of source property in LocalStorage 2224 * @param { T } defaultValue - value to be used for initializing new property in LocalStorage 2225 * default value must be of type T, can be undefined or null. 2226 * @returns { SubscribedAbstractProperty<T> } instance of SubscribedAbstractProperty<T> 2227 * Apps can use SDK functions of base class SubscribedAbstractProperty<T> 2228 * @syscap SystemCapability.ArkUI.ArkUI.Full 2229 * @crossplatform 2230 * @form 2231 * @atomicservice 2232 * @since 12 2233 */ 2234 setAndLink<T>(propName: string, defaultValue: T): SubscribedAbstractProperty<T>; 2235 2236 /** 2237 * Create and return a one-way sync ('prop') to named property 2238 * 2239 * @param { string } propName - name of source property in LocalStorage 2240 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2241 * return undefined if named property does not already exist in LocalStorage 2242 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2243 * @syscap SystemCapability.ArkUI.ArkUI.Full 2244 * @form 2245 * @since 9 2246 */ 2247 /** 2248 * Create and return a one-way sync ('prop') to named property 2249 * 2250 * @param { string } propName - name of source property in LocalStorage 2251 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2252 * return undefined if named property does not already exist in LocalStorage 2253 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2254 * @syscap SystemCapability.ArkUI.ArkUI.Full 2255 * @crossplatform 2256 * @form 2257 * @since 10 2258 */ 2259 /** 2260 * Create and return a one-way sync ('prop') to named property 2261 * 2262 * @param { string } propName - name of source property in LocalStorage 2263 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2264 * return undefined if named property does not already exist in LocalStorage 2265 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2266 * @syscap SystemCapability.ArkUI.ArkUI.Full 2267 * @crossplatform 2268 * @form 2269 * @atomicservice 2270 * @since 11 2271 */ 2272 prop<S>(propName: string): SubscribedAbstractProperty<S>; 2273 2274 /** 2275 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2276 * 2277 * @param { string } propName - name of source property in LocalStorage 2278 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2279 * Default value must be of type T, must not be undefined or null. 2280 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2281 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2282 * @syscap SystemCapability.ArkUI.ArkUI.Full 2283 * @form 2284 * @since 9 2285 */ 2286 /** 2287 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2288 * 2289 * @param { string } propName - name of source property in LocalStorage 2290 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2291 * Default value must be of type T, must not be undefined or null. 2292 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2293 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2294 * @syscap SystemCapability.ArkUI.ArkUI.Full 2295 * @crossplatform 2296 * @form 2297 * @since 10 2298 */ 2299 /** 2300 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2301 * 2302 * @param { string } propName - name of source property in LocalStorage 2303 * @param { S } defaultValue - value to be used for initializing if new creating new property in LocalStorage. 2304 * Default value must be of type T, must not be undefined or null. 2305 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2306 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2307 * @syscap SystemCapability.ArkUI.ArkUI.Full 2308 * @crossplatform 2309 * @form 2310 * @atomicservice 2311 * @since 11 2312 */ 2313 /** 2314 * Like see prop(), will create and initialize a new source property in LocalStorage if missing 2315 * 2316 * @param { string } propName - name of source property in LocalStorage 2317 * @param { S } defaultValue - value to be used for initializing new property in LocalStorage. 2318 * Default value must be of type T, can be undefined or null. 2319 * @returns { SubscribedAbstractProperty<S> } instance of SubscribedAbstractProperty<S> 2320 * Apps can use SDK functions of base class SubscribedAbstractProperty<S> 2321 * @syscap SystemCapability.ArkUI.ArkUI.Full 2322 * @crossplatform 2323 * @form 2324 * @atomicservice 2325 * @since 12 2326 */ 2327 setAndProp<S>(propName: string, defaultValue: S): SubscribedAbstractProperty<S>; 2328 2329 /** 2330 * Delete property from StorageBase 2331 * Use with caution: 2332 * Before deleting a prop from LocalStorage all its subscribers need to 2333 * unsubscribe from the property. 2334 * This method fails and returns false if given property still has subscribers 2335 * Another reason for failing is unknown property. 2336 * Developer advise: 2337 * Subscribers are created with see link(), see prop() 2338 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2339 * That means as long as their is a @Component instance that uses such decorated variable 2340 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2341 * (and also should not!) be deleted from LocalStorage. 2342 * 2343 * @param { string } propName 2344 * @returns { boolean } false if method failed 2345 * @syscap SystemCapability.ArkUI.ArkUI.Full 2346 * @form 2347 * @since 9 2348 */ 2349 /** 2350 * Delete property from StorageBase 2351 * Use with caution: 2352 * Before deleting a prop from LocalStorage all its subscribers need to 2353 * unsubscribe from the property. 2354 * This method fails and returns false if given property still has subscribers 2355 * Another reason for failing is unknown property. 2356 * Developer advise: 2357 * Subscribers are created with see link(), see prop() 2358 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2359 * That means as long as their is a @Component instance that uses such decorated variable 2360 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2361 * (and also should not!) be deleted from LocalStorage. 2362 * 2363 * @param { string } propName 2364 * @returns { boolean } false if method failed 2365 * @syscap SystemCapability.ArkUI.ArkUI.Full 2366 * @crossplatform 2367 * @form 2368 * @since 10 2369 */ 2370 /** 2371 * Delete property from StorageBase 2372 * Use with caution: 2373 * Before deleting a prop from LocalStorage all its subscribers need to 2374 * unsubscribe from the property. 2375 * This method fails and returns false if given property still has subscribers 2376 * Another reason for failing is unknown property. 2377 * Developer advise: 2378 * Subscribers are created with see link(), see prop() 2379 * and also via @LocalStorageLink and @LocalStorageProp state variable decorators. 2380 * That means as long as their is a @Component instance that uses such decorated variable 2381 * or a sync relationship with a SubscribedAbstractProperty variable the property can nit 2382 * (and also should not!) be deleted from LocalStorage. 2383 * 2384 * @param { string } propName 2385 * @returns { boolean } false if method failed 2386 * @syscap SystemCapability.ArkUI.ArkUI.Full 2387 * @crossplatform 2388 * @form 2389 * @atomicservice 2390 * @since 11 2391 */ 2392 delete(propName: string): boolean; 2393 2394 /** 2395 * Delete all properties from the LocalStorage instance 2396 * Precondition is that there are no subscribers. 2397 * method returns false and deletes no properties if there is any property 2398 * that still has subscribers 2399 * 2400 * @returns { boolean } 2401 * @syscap SystemCapability.ArkUI.ArkUI.Full 2402 * @form 2403 * @since 9 2404 */ 2405 /** 2406 * Delete all properties from the LocalStorage instance 2407 * Precondition is that there are no subscribers. 2408 * method returns false and deletes no properties if there is any property 2409 * that still has subscribers 2410 * 2411 * @returns { boolean } 2412 * @syscap SystemCapability.ArkUI.ArkUI.Full 2413 * @crossplatform 2414 * @form 2415 * @since 10 2416 */ 2417 /** 2418 * Delete all properties from the LocalStorage instance 2419 * Precondition is that there are no subscribers. 2420 * method returns false and deletes no properties if there is any property 2421 * that still has subscribers 2422 * 2423 * @returns { boolean } 2424 * @syscap SystemCapability.ArkUI.ArkUI.Full 2425 * @crossplatform 2426 * @form 2427 * @atomicservice 2428 * @since 11 2429 */ 2430 clear(): boolean; 2431} 2432