@fozy-labs/rx-toolkit 0.5.0-rc.0 → 0.5.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,11 +18,11 @@ export declare class LocalSignal<T = string | null | number | undefined> {
18
18
  private _signal;
19
19
  private _computed;
20
20
  private readonly _options;
21
+ readonly obs: Observable<T>;
21
22
  constructor(options: Options<T>);
22
23
  set(value: T): void;
23
24
  peek(): T;
24
25
  get(): T;
25
- obs(): Observable<T>;
26
26
  static KEY_PREFIX: string;
27
27
  static DRIVER: Storage;
28
28
  static create<T = string | null | number | undefined>(options: Options<T>): SignalFn<T>;
@@ -2,12 +2,12 @@ import { z } from "zod/v4";
2
2
  import { signalize } from "../operators";
3
3
  import { Signal } from "./Signal";
4
4
  import { Computed } from "./Computed";
5
- const NullOrString = z.string().nullable();
6
5
  const NONE = Symbol('NONE');
7
6
  export class LocalSignal {
8
7
  _signal;
9
8
  _computed;
10
9
  _options;
10
+ obs;
11
11
  constructor(options) {
12
12
  let initialValue = LocalSignal._getStorageValue(options);
13
13
  if (initialValue === NONE) {
@@ -28,6 +28,7 @@ export class LocalSignal {
28
28
  }
29
29
  return value;
30
30
  }, options.devtoolsOptions);
31
+ this.obs = this._computed.obs;
31
32
  this._options = options;
32
33
  }
33
34
  set(value) {
@@ -40,9 +41,6 @@ export class LocalSignal {
40
41
  get() {
41
42
  return this._computed.get();
42
43
  }
43
- obs() {
44
- return this._computed.obs;
45
- }
46
44
  // === static ===
47
45
  static KEY_PREFIX = '__LSValue__';
48
46
  static DRIVER = localStorage;
@@ -62,7 +60,7 @@ export class LocalSignal {
62
60
  const item = LocalSignal.DRIVER.getItem(storageKey);
63
61
  if (!item)
64
62
  return NONE;
65
- const schema = z.record(z.string(), options.zodSchema || NullOrString);
63
+ const schema = z.record(z.string(), options.zodSchema || z.any());
66
64
  const parsed = schema.safeParse(JSON.parse(item));
67
65
  if (!parsed.success) {
68
66
  console.warn(`Invalid value for key "${options.key}" in localStorage`, parsed.error);
@@ -77,7 +75,7 @@ export class LocalSignal {
77
75
  static _setStorageValue(options, value) {
78
76
  const storageKey = `${LocalSignal.KEY_PREFIX}:${options.key}`;
79
77
  const item = LocalSignal.DRIVER.getItem(storageKey) || '{}';
80
- const schema = z.record(z.string(), options.zodSchema || NullOrString);
78
+ const schema = z.record(z.string(), options.zodSchema || z.any());
81
79
  const parsed = schema.safeParse(JSON.parse(item));
82
80
  let data = parsed.data ?? {};
83
81
  if (!parsed.success) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fozy-labs/rx-toolkit",
3
- "version": "0.5.0-rc.0",
3
+ "version": "0.5.0-rc.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",