Files
SubMiner/vendor/texthooker-ui/src/stores/transformer/writeable-object-sibject.ts
2026-02-09 19:04:19 -08:00

17 lines
433 B
TypeScript

import { writableStorageSubject } from './writable-storage-subject';
function createwritteableObjectSubject<T>(fallback: string) {
return writableStorageSubject(
(x) => JSON.parse(x || fallback) as T,
(x) => JSON.stringify(x)
);
}
export function writeableObjectSubject<T>() {
return createwritteableObjectSubject<T>('{}');
}
export function writeableArraySubject<T>() {
return createwritteableObjectSubject<T[]>('[]');
}