cogsbox-state 0.5.470 → 0.5.471
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 +0 -46
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,17 +196,6 @@ const todos = useCogsState('todos');
|
|
|
196
196
|
))}
|
|
197
197
|
```
|
|
198
198
|
|
|
199
|
-
#### `$stateMap()` - Signal-Based Rendering
|
|
200
|
-
|
|
201
|
-
```typescript
|
|
202
|
-
const todos = useCogsState('todos');
|
|
203
|
-
|
|
204
|
-
// Most efficient - updates only changed items, no React re-renders
|
|
205
|
-
{todos.$stateMap((todoState, index, arrayState) => (
|
|
206
|
-
<TodoItem todo={todoState} />
|
|
207
|
-
))}
|
|
208
|
-
```
|
|
209
|
-
|
|
210
199
|
### Advanced Array Methods
|
|
211
200
|
|
|
212
201
|
#### Filtering and Sorting
|
|
@@ -358,41 +347,6 @@ const user = useCogsState('user', {
|
|
|
358
347
|
});
|
|
359
348
|
```
|
|
360
349
|
|
|
361
|
-
## Signal-Based Updates
|
|
362
|
-
|
|
363
|
-
The most efficient rendering method - bypasses React entirely:
|
|
364
|
-
|
|
365
|
-
```typescript
|
|
366
|
-
function PerformantComponent() {
|
|
367
|
-
const user = useCogsState('user', { reactiveType: 'none' });
|
|
368
|
-
const todos = useCogsState('todos', { reactiveType: 'none' });
|
|
369
|
-
|
|
370
|
-
return (
|
|
371
|
-
<div>
|
|
372
|
-
{/* These update DOM directly, no React re-renders */}
|
|
373
|
-
<div>Name: {user.name.$get()}</div>
|
|
374
|
-
<div>Counter: {user.stats.counter.$get()}</div>
|
|
375
|
-
<div>Todo Count: {todos.$derive(todos => todos.length)}</div>
|
|
376
|
-
|
|
377
|
-
{/* Signal-based list rendering */}
|
|
378
|
-
{todos.$stateMap((todo, index) => (
|
|
379
|
-
<div key={todo.id.$get()}>
|
|
380
|
-
<span>{todo.text.$get()}</span>
|
|
381
|
-
<button onClick={() => todo.done.$toggle()}>Toggle</button>
|
|
382
|
-
</div>
|
|
383
|
-
))}
|
|
384
|
-
|
|
385
|
-
{/* Wrap with formElement for isolated reactivity */}
|
|
386
|
-
{user.stats.counter.formElement((obj) => (
|
|
387
|
-
<button onClick={() => obj.$update(prev => prev + 1)}>
|
|
388
|
-
Increment: {obj.$get()}
|
|
389
|
-
</button>
|
|
390
|
-
))}
|
|
391
|
-
</div>
|
|
392
|
-
);
|
|
393
|
-
}
|
|
394
|
-
```
|
|
395
|
-
|
|
396
350
|
## Form Management
|
|
397
351
|
|
|
398
352
|
Cogsbox excels at form handling with automatic debouncing and validation:
|