@ydant/reactive 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +12 -10
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -41,8 +41,8 @@ dispose(); // Stop tracking
41
41
  ### With DOM (reactive primitive)
42
42
 
43
43
  ```typescript
44
- import { div, button, text, on, type Component } from "@ydant/core";
45
- import { mount } from "@ydant/dom";
44
+ import { mount, type Component } from "@ydant/core";
45
+ import { createBasePlugin, div, button, text, on } from "@ydant/base";
46
46
  import { signal, reactive, createReactivePlugin } from "@ydant/reactive";
47
47
 
48
48
  const count = signal(0);
@@ -56,7 +56,7 @@ const Counter: Component = () =>
56
56
  });
57
57
 
58
58
  mount(Counter, document.getElementById("app")!, {
59
- plugins: [createReactivePlugin()],
59
+ plugins: [createBasePlugin(), createReactivePlugin()],
60
60
  });
61
61
  ```
62
62
 
@@ -67,10 +67,11 @@ mount(Counter, document.getElementById("app")!, {
67
67
  ```typescript
68
68
  function signal<T>(initialValue: T): Signal<T>;
69
69
 
70
- interface Signal<T> {
71
- (): T; // Read
70
+ interface Signal<T> extends Readable<T> {
71
+ (): T; // Read (tracks dependencies)
72
+ peek(): T; // Read without tracking
72
73
  set(value: T): void; // Write
73
- update(fn: (v: T) => T): void; // Update with function
74
+ update(fn: (prev: T) => T): void; // Update with function
74
75
  }
75
76
  ```
76
77
 
@@ -79,8 +80,9 @@ interface Signal<T> {
79
80
  ```typescript
80
81
  function computed<T>(fn: () => T): Computed<T>;
81
82
 
82
- interface Computed<T> {
83
+ interface Computed<T> extends Readable<T> {
83
84
  (): T; // Read (automatically tracks dependencies)
85
+ peek(): T; // Read without tracking
84
86
  }
85
87
  ```
86
88
 
@@ -129,14 +131,14 @@ Without `batch`, each `set()` call would trigger the effect immediately. With `b
129
131
  ### createReactivePlugin
130
132
 
131
133
  ```typescript
132
- function createReactivePlugin(): DomPlugin;
134
+ function createReactivePlugin(): Plugin;
133
135
  ```
134
136
 
135
- Creates a DOM plugin that handles `reactive` blocks. Must be passed to `mount()`.
137
+ Creates a plugin that handles `reactive` blocks. Must be passed to `mount()`. Depends on `createBasePlugin()`.
136
138
 
137
139
  ## Module Structure
138
140
 
139
- - `types.ts` - Subscriber type
141
+ - `types.ts` - Subscriber, Readable types
140
142
  - `signal.ts` - Signal implementation
141
143
  - `computed.ts` - Computed implementation
142
144
  - `effect.ts` - Effect implementation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ydant/reactive",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Reactivity system for Ydant",
5
5
  "keywords": [
6
6
  "reactive",
@@ -39,8 +39,8 @@
39
39
  }
40
40
  },
41
41
  "peerDependencies": {
42
- "@ydant/base": "0.1.0",
43
- "@ydant/core": "0.1.0"
42
+ "@ydant/base": "0.1.2",
43
+ "@ydant/core": "0.1.1"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "vite build",