Server: Phase 2 (REVIEW not respected yet)

This commit is contained in:
Thomas Karner committed 2026-09-21 11:24:43 +02:00
1 parent 5d16ded553
commit 142b47674d
4271 files changed
+1203269

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
const require_atom = require('./atom.cjs');
//#region src/store.ts
var Store = class {
constructor(valueOrFn, actionsFactory) {
this.atom = require_atom.createAtom(valueOrFn);
this.get = this.get.bind(this);
this.setState = this.setState.bind(this);
this.subscribe = this.subscribe.bind(this);
if (actionsFactory) this.actions = actionsFactory(this);
}
setState(updater) {
this.atom.set(updater);
}
get state() {
return this.atom.get();
}
get() {
return this.state;
}
subscribe(observerOrFn) {
return this.atom.subscribe(require_atom.toObserver(observerOrFn));
}
};
var ReadonlyStore = class {
constructor(valueOrFn) {
this.atom = require_atom.createAtom(valueOrFn);
}
get state() {
return this.atom.get();
}
get() {
return this.state;
}
subscribe(observerOrFn) {
return this.atom.subscribe(require_atom.toObserver(observerOrFn));
}
};
function createStore(valueOrFn, actions) {
if (typeof valueOrFn === "function") return new ReadonlyStore(valueOrFn);
if (actions) return new Store(valueOrFn, actions);
return new Store(valueOrFn);
}
//#endregion
exports.ReadonlyStore = ReadonlyStore;
exports.Store = Store;
exports.createStore = createStore;
//# sourceMappingURL=store.cjs.map