mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 18:22:41 -08:00
17 lines
433 B
TypeScript
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[]>('[]');
|
|
}
|