state-ref

Creates reactive web and mobile apps with a unified JavaScript API.

54|1|Updated Sep 20, 2024
One-click install
npx skills add https://github.com/superlucky84/state-ref --skill state-ref
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: state-ref
Source: https://github.com/superlucky84/state-ref/tree/main/skills/state-ref
Command: npx skills add https://github.com/superlucky84/state-ref --skill state-ref

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

State management in modern UI apps often struggles with brittle mutations and scattered updates. state-ref provides proxy-based stores and lens-pattern updates to enable fine-grained, safe reactivity with automatic dependency tracking.

Core Features & Use Cases

  • Create stores with createStore and subscribe with watch to react to changes.
  • Combine multiple stores with combineWatch and derive computed values with createComputed.
  • Framework connectors for React, Preact, Vue, Svelte, and Solid; manual-sync patterns via createStoreManualSync.
  • Encourage safe mutation practices: read through the value property, use AbortController for cleanup, and leverage immutable patterns with copyable and lens.

Quick Start

Install state-ref, create a store with createStore, and attach a watch callback to react to changes.

Frequently Asked Questions about state-ref

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does proxy-based state reactivity handle fine-grained updates in UI frameworks?

You create a store using createStore or createStoreManualSync, read values via the .value property, and attach a watch callback to subscribe to changes. This enables automatic dependency tracking and reactive updates whenever the state mutates.

Does state-ref work with React, Vue, Svelte, and Solid for state management?

Yes, state-ref provides framework connectors for React, Preact, Vue, Svelte, and Solid, enabling proxy-based stores to integrate directly with your UI components for seamless reactive updates.

How do I combine multiple stores and derive computed values in a reactivity system?

You combine multiple stores using combineWatch for multi-store composition and derive values with createComputed. This allows automatic recalculation whenever underlying proxy-based store dependencies change.

What is the best way to ensure safe state mutations and cleanup with proxy stores?

To ensure safe state mutations, read through the value property and leverage immutable patterns with copyable and lens. For cleanup, use AbortController when subscribing with watch to prevent memory leaks.

Why use a lens pattern for state updates instead of direct mutations?

A lens pattern enables targeted, fine-grained updates to nested state structures without brittle direct mutations. This approach maintains immutability and prevents scattered updates across proxy-based reactive stores.