1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | import { MDCFoundation } from './foundation';
|
24 | import { Observer, ObserverRecord } from './observer';
|
25 | export declare class MDCObserverFoundation<Adapter> extends MDCFoundation<Adapter> {
|
26 |
|
27 | protected unobserves: Set<Function>;
|
28 | constructor(adapter: Adapter);
|
29 | destroy(): void;
|
30 | /**
|
31 | * Observe a target's properties for changes using the provided map of
|
32 | * property names and observer functions.
|
33 | *
|
34 | * @template T The target type.
|
35 | * @param target - The target to observe.
|
36 | * @param observers - An object whose keys are target properties and values
|
37 | * are observer functions that are called when the associated property
|
38 | * changes.
|
39 | * @return A cleanup function that can be called to unobserve the
|
40 | * target.
|
41 | */
|
42 | protected observe<T extends object>(target: T, observers: ObserverRecord<T, this>): () => void;
|
43 | /**
|
44 | * Observe a target's property for changes. When a property changes, the
|
45 | * provided `Observer` function will be invoked with the properties current
|
46 | * and previous values.
|
47 | *
|
48 | * The returned cleanup function will stop listening to changes for the
|
49 | * provided `Observer`.
|
50 | *
|
51 | * @template T The observed target type.
|
52 | * @template K The observed property.
|
53 | * @param target - The target to observe.
|
54 | * @param property - The property of the target to observe.
|
55 | * @param observer - An observer function to invoke each time the property
|
56 | * changes.
|
57 | * @return A cleanup function that will stop observing changes for the
|
58 | * provided `Observer`.
|
59 | */
|
60 | protected observeProperty<T extends object, K extends keyof T>(target: T, property: K, observer: Observer<T, K>): () => void;
|
61 | /**
|
62 | * Enables or disables all observers for the provided target. Disabling
|
63 | * observers will prevent them from being called until they are re-enabled.
|
64 | *
|
65 | * @param target - The target to enable or disable observers for.
|
66 | * @param enabled - Whether or not observers should be called.
|
67 | */
|
68 | protected setObserversEnabled(target: object, enabled: boolean): void;
|
69 | /**
|
70 | * Clean up all observers and stop listening for property changes.
|
71 | */
|
72 | protected unobserve(): void;
|
73 | }
|