@interactify-live/player-react-native
Version:
React Native library for Interactify player with media display, widgets, and MQTT integration
31 lines (30 loc) • 711 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Observable = void 0;
class Observable {
constructor(value) {
this.callbacks = new Set();
this.value = value;
}
set(value) {
if (this.value === value) {
return this;
}
this.value = value;
this.callbacks.forEach(callback => callback(value));
return this;
}
get() {
return this.value;
}
subscribe(callback) {
this.callbacks.add(callback);
return () => {
this.callbacks.delete(callback);
};
}
destroy() {
this.callbacks = new Set();
}
}
exports.Observable = Observable;