1 | /**
|
2 | * @license
|
3 | * Copyright 2021 Google Inc.
|
4 | *
|
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 | * of this software and associated documentation files (the "Software"), to deal
|
7 | * in the Software without restriction, including without limitation the rights
|
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 | * copies of the Software, and to permit persons to whom the Software is
|
10 | * furnished to do so, subject to the following conditions:
|
11 | *
|
12 | * The above copyright notice and this permission notice shall be included in
|
13 | * all copies or substantial portions of the Software.
|
14 | *
|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21 | * THE SOFTWARE.
|
22 | */
|
23 | import { MDCObserver, Observer } from './observer';
|
24 | import { Constructor } from './types';
|
25 | /**
|
26 | * Mixin to add `MDCObserver` functionality.
|
27 | *
|
28 | * @deprecated Prefer MDCObserverFoundation for stricter closure compliance.
|
29 | * @return A class with `MDCObserver` functionality.
|
30 | */
|
31 | export declare function mdcObserver(): Constructor<MDCObserver>;
|
32 | /**
|
33 | * Mixin to add `MDCObserver` functionality to a base class.
|
34 | *
|
35 | * @deprecated Prefer MDCObserverFoundation for stricter closure compliance.
|
36 | * @template T Base class instance type. Specify this generic if the base class
|
37 | * itself has generics that cannot be inferred.
|
38 | * @template C Base class constructor type.
|
39 | * @param baseClass - Base class.
|
40 | * @return A class that extends the optional base class with `MDCObserver`
|
41 | * functionality.
|
42 | */
|
43 | export declare function mdcObserver<T, C extends Constructor<T>>(baseClass: C): Constructor<MDCObserver> & Constructor<T> & C;
|
44 | /**
|
45 | * Observe a target's property for changes. When a property changes, the
|
46 | * provided `Observer` function will be invoked with the properties current and
|
47 | * previous values.
|
48 | *
|
49 | * The returned cleanup function will stop listening to changes for the
|
50 | * provided `Observer`.
|
51 | *
|
52 | * @template T The observed target type.
|
53 | * @template K The observed property.
|
54 | * @param target - The target to observe.
|
55 | * @param property - The property of the target to observe.
|
56 | * @param observer - An observer function to invoke each time the property
|
57 | * changes.
|
58 | * @return A cleanup function that will stop observing changes for the provided
|
59 | * `Observer`.
|
60 | */
|
61 | export declare function observeProperty<T extends object, K extends keyof T>(target: T, property: K, observer: Observer<T, K>): () => void;
|
62 | /**
|
63 | * Enables or disables all observers for a provided target. Changes to observed
|
64 | * properties will not call any observers when disabled.
|
65 | *
|
66 | * @template T The observed target type.
|
67 | * @param target - The target to enable or disable observers for.
|
68 | * @param enabled - True to enable or false to disable observers.
|
69 | */
|
70 | export declare function setObserversEnabled<T extends object>(target: T, enabled: boolean): void;
|