@shopify/react-native-skia
Version:
High-performance React Native Graphics using Skia
42 lines (31 loc) • 951 B
JavaScript
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
export class RNSkReadonlyValue {
constructor(value) {
_defineProperty(this, "_current", void 0);
_defineProperty(this, "_listeners", []);
_defineProperty(this, "__typename__", "RNSkValue");
this._current = value;
}
notifyListeners() {
this._listeners.forEach(cb => cb(this._current));
}
update(nextValue) {
if (this._current !== nextValue) {
this._current = nextValue;
this.notifyListeners();
}
}
get current() {
return this._current;
}
addListener(cb) {
this._listeners.push(cb);
return () => {
this._listeners.splice(this._listeners.indexOf(cb), 1);
};
}
dispose() {
this._listeners = [];
}
}
//# sourceMappingURL=RNSkReadonlyValue.js.map