UNPKG

1.1 kBJavaScriptView Raw
1import { Observable } from '../data/observable';
2export class SharedA11YObservable extends Observable {
3}
4export const AccessibilityServiceEnabledPropName = 'accessibilityServiceEnabled';
5export class CommonA11YServiceEnabledObservable extends SharedA11YObservable {
6 constructor(sharedA11YObservable) {
7 super();
8 const ref = new WeakRef(this);
9 let lastValue;
10 function callback() {
11 const self = ref?.get();
12 if (!self) {
13 sharedA11YObservable.off(Observable.propertyChangeEvent, callback);
14 return;
15 }
16 const newValue = !!sharedA11YObservable.accessibilityServiceEnabled;
17 if (newValue !== lastValue) {
18 self.set(AccessibilityServiceEnabledPropName, newValue);
19 lastValue = newValue;
20 }
21 }
22 sharedA11YObservable.on(Observable.propertyChangeEvent, callback);
23 this.set(AccessibilityServiceEnabledPropName, !!sharedA11YObservable.accessibilityServiceEnabled);
24 }
25}
26//# sourceMappingURL=accessibility-service-common.js.map
\No newline at end of file