casparcg-state
Version:
Node.js Javascript/Typescript library for keeping and resolving a given state of CasparCG into commands for casparcg-connection.
47 lines • 1.29 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateObjectStorage = void 0;
/**
* StateObjectStorage is used for exposing the internal state variable
* By default, it is storing the state as an internal variable,
* byt may be using an external storage function for fetching/storing the state.
*/
class StateObjectStorage {
constructor() {
this._internalState = {
channels: {},
};
this._externalStorage = null;
}
assignExternalStorage(fcn) {
this._externalStorage = fcn ?? null;
}
fetchState() {
if (this._externalStorage) {
return this._externalStorage('fetch', null);
}
else {
return this._internalState;
}
}
storeState(data) {
if (this._externalStorage) {
this._externalStorage('store', data);
}
else {
this._internalState = data;
}
}
clearState() {
if (this._externalStorage) {
this._externalStorage('clear');
}
else {
this._internalState = {
channels: {},
};
}
}
}
exports.StateObjectStorage = StateObjectStorage;
//# sourceMappingURL=stateObjectStorage.js.map
;