• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16type PropertyInfo = string;
17
18/**
19  * The IPropertySubscriber interface describes an instance that can subscribes
20  * to various changes of app state.
21  * It must have a gloabbly unique id
22*/
23interface IPropertySubscriber {
24
25  // globally unique id
26  id__(): number;
27
28  /**
29   *  inform the subscribed property
30   * that the subscriber is about to be deleted
31   * hence , unsubscribe
32   */
33  aboutToBeDeleted(owningView?: IPropertySubscriber): void;
34}
35
36/**
37 * The ISinglePropertyChangeSubscriber<T> describes an
38 * instance that subscribes to a source that manages a single app state property.
39 * That instances expects to receive hasChanged() events with the new property value.
40 * This property is of type T.
41 */
42interface ISinglePropertyChangeSubscriber<T> extends IPropertySubscriber {
43
44  /**
45   * get informed after the property has changed.
46   */
47  hasChanged(newValue: T): void;
48}
49
50/**
51 * The IMultiPropertiesChangeSubscriber<T> describes an
52 * instance that subscribes to a source that manages multiple app state properties.
53 * That instances expects to receive propertyHasChanged() events with the changed property name
54 * as a parameter.
55 */
56interface IMultiPropertiesChangeSubscriber extends IPropertySubscriber {
57  // get informed that given property has changed.
58  // Note: a Property's PropertyInfo can be undefined.
59  propertyHasChanged(info?: PropertyInfo): void;
60}
61
62/**
63 * The IMultiPropertiesReadSubscriber<T> describes an
64 * instance that subscribes to a source that manages multiple app state properties.
65 * That instances expects to receive propertyRead() events with the read property name
66 * as a parameter. These events will typically only fire if read access recording
67 * has been explicitely enabled
68 *
69 * Not a public / sdk interface
70 */
71 interface IMultiPropertiesReadSubscriber extends IPropertySubscriber {
72  // get informed that given property has been read (get access).
73  // Note: a Property's PropertyInfo can be undefined.
74  propertyRead(info?: PropertyInfo): void;
75}
76
77/**
78 * ViewPU implements IViewPropertiesChangeSubscriber<T>/
79 * The ViewPU expects to receive viewPropertyHasChanged() events with the changed property name
80 * and a Set of dependent elementIds / nodeIds as a parameters.
81 *
82 * Not a public / sdk interface
83*
84*/
85interface IViewPropertiesChangeSubscriber extends IPropertySubscriber {
86  // ViewPU get informed when View variable has changed
87  // informs the elmtIds that need update upon variable change
88  viewPropertyHasChanged(varName: PropertyInfo, dependentElmtIds: Set<number>): void ;
89}
90