memorio 4.3.5 → 4.5.0

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.
package/README.md CHANGED
@@ -44,13 +44,14 @@ All from one import, zero configuration.
44
44
 
45
45
  | | |
46
46
  |---|---|
47
- | **`state`** | Reactive, volatile state — listen with `useObserver` |
47
+ | **`state`** | Reactive, volatile state — observe with `useObserver` (React) or `dispatch.listen` (vanilla JS) |
48
48
  | **`store`** | localStorage persistence — survives refresh |
49
49
  | **`session`** | sessionStorage — dies with the tab |
50
50
  | **`cache`** | In-memory cache — fastest read possible |
51
51
  | **`idb`** | IndexedDB with typed tables — structured, persistent, async |
52
- | **`observer`** | Object watcher legacy, still works |
52
+ | **`observer`** | Object watcher - legacy API for vanilla JS |
53
53
  | **`useObserver`** | React hook with auto-discovery — drops in |
54
+ | **`dispatch`** | Event system for vanilla JS — listen, emit, subscribe |
54
55
  | **`devtools`** | `memorio.devtools.inspect()` — see everything in console |
55
56
  | **`logger`** | Auto-log every state change with timestamps |
56
57
  | **Session Isolation** | Every browser tab, every request: isolated namespace |
@@ -91,11 +92,16 @@ state.user = { name: 'Sara', role: 'admin' }
91
92
  state.counter++
92
93
  state.settings = { theme: 'dark', lang: 'it' }
93
94
 
94
- // Call it "a store" but make it observe automatically
95
+ // React - automatic dependency discovery
95
96
  useObserver(
96
97
  () => { console.debug('user changed:', state.user) },
97
98
  [state.user]
98
99
  )
100
+
101
+ // Vanilla JS - event system
102
+ memorio.dispatch.listen('state.user', (event) => {
103
+ console.debug('user changed:', event.detail);
104
+ })
99
105
  ```
100
106
 
101
107
  That is it.
@@ -166,7 +172,7 @@ await idb.data.set('my-db', 'users', { id: 1, name: 'Sara' })
166
172
  const user = await idb.data.get('my-db', 'users', 1)
167
173
  ```
168
174
 
169
- ### `observer` — Object watcher (DEPRECATED)
175
+ ### `observer` — Object watcher
170
176
 
171
177
  ```javascript
172
178
  globalThis.observer('state.user', (newVal, oldVal) => {
package/SUMMARY.md CHANGED
@@ -5,8 +5,9 @@
5
5
  ## Core Modules
6
6
 
7
7
  * [State](markdown/STATE.md) - Reactive global state management
8
- * [Observer](markdown/OBSERVER.md) - ⚠️ Deprecated (use useObserver)
8
+ * [Observer](markdown/OBSERVER.md) - Object observation pattern
9
9
  * [useObserver](markdown/USEOBSERVER.md) - React hook for state observation
10
+ * [Dispatch](markdown/DISPATCH.md) - Event system for vanilla JS applications
10
11
  * [Cache](markdown/CACHE.md) - In-memory caching (lost on refresh)
11
12
  * [Store](markdown/STORE.md) - Persistent localStorage management
12
13
  * [Session](markdown/SESSION.md) - Temporary sessionStorage management