/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ interface IPropertySubscriber { id(): number; aboutToBeDeleted(owningView?: IPropertySubscriber): void; } interface ISinglePropertyChangeSubscriber extends IPropertySubscriber { hasChanged(newValue: T): void; } declare abstract class SubscribedAbstractProperty { protected subscribers_: Set; private id_; private info_?; constructor(subscribeMe?: IPropertySubscriber, info?: string); id(): number; info(): string; abstract get(): T; abstract set(newValue: T): void; createTwoWaySync(subscribeMe?: IPropertySubscriber, info?: string): SyncedPropertyTwoWay; createOneWaySync(subscribeMe?: IPropertySubscriber, info?: string): SyncedPropertyOneWay; unlinkSuscriber(subscriberId: number): void; protected notifyHasChanged(newValue: T): void; protected notifyPropertyRead(): void; numberOfSubscrbers(): number; } declare class SyncedPropertyTwoWay extends SubscribedAbstractProperty implements ISinglePropertyChangeSubscriber { private source_; constructor(source: SubscribedAbstractProperty, subscribeMe?: IPropertySubscriber, info?: string); aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber): void; hasChanged(newValue: T): void; get(): T; set(newValue: T): void; } declare class SyncedPropertyOneWay extends SubscribedAbstractProperty implements ISinglePropertyChangeSubscriber { private wrappedValue_; private source_; constructor(source: SubscribedAbstractProperty, subscribeMe?: IPropertySubscriber, info?: string); aboutToBeDeleted(unsubscribeMe?: IPropertySubscriber): void; hasChanged(newValue: T): void; get(): T; set(newValue: T): void; } export declare class AppStorage { static Link(propName: string): any; static SetAndLink(propName: string, defaultValue: T): SubscribedAbstractProperty; static Prop(propName: string): any; static SetAndProp(propName: string, defaultValue: S): SubscribedAbstractProperty; static Has(propName: string): boolean; static Get(propName: string): T | undefined; static Set(propName: string, newValue: T): boolean; static SetOrCreate(propName: string, newValue: T): void; static Delete(propName: string): boolean; static Keys(): IterableIterator; static staticClear(): boolean; static IsMutable(propName: string): boolean; static Size(): number; } export declare class Environment { constructor(); static EnvProp(key: string, value: S): boolean; static EnvProps(props: { key: string; defaultValue: any; }[]): void; static Keys(): Array; } export declare enum ColorMode { LIGHT = 0, DARK, } export declare enum LayoutDirection { LTR = 0, RTL, } export declare class PersistentStorage { constructor(appStorage: AppStorage, storage: Storage); static PersistProp(key: string, defaultValue: T): void; static DeleteProp(key: string): void; static PersistProps(properties: { key: string; defaultValue: any; }[]): void; static Keys(): Array; } export declare class Storage { constructor(needCrossThread?: boolean, file?: string); get(key: string): string | undefined; set(key: string, val: any): void; clear(): void; delete(key: string): void; } export declare abstract class SubscribaleAbstract { private owningProperties_: Set; constructor(); protected notifyPropertyHasChanged(propName: string, newValue: any): void; public addOwningProperty(subscriber: IPropertySubscriber): void; public removeOwningProperty(property: IPropertySubscriber): void; public removeOwningPropertyById(subscriberId: number): void; } export declare const appStorage: AppStorage;