ワンクリックで
state-ref
Use when working in projects that use state-ref; follow proxy-based reactivity and lens pattern guidelines.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when working in projects that use state-ref; follow proxy-based reactivity and lens pattern guidelines.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | state-ref |
| description | Use when working in projects that use state-ref; follow proxy-based reactivity and lens pattern guidelines. |
| metadata | {"short-description":"state-ref workflow","version":{"[object Object]":null}} |
Document Version: {{version}}
Additional materials (optional):
These guidelines apply only when state-ref is installed in the current project.
Before following this document:
package.json for state-ref in dependencies/devDependenciesnode_modules/state-ref existsstate-refIf state-ref is not installed, use the project's existing conventions. Do not suggest adding state-ref unless the user asks.
createStore<T>(initialValue) for auto-sync mode..value property on StateRefStore proxies.watch(callback) - callback receives (stateRef, isFirst)..value reads inside callbacks trigger re-runs on change.AbortController.signal returned from callback to unsubscribe.createStoreManualSync() for Flux-like patterns with updateRef and sync().connectReact, connectPreact, connectVue, connectSvelte, connectSolid.combineWatch([watch1, watch2] as const).createComputed([watches], callback).copyable() for manual copy-on-write updates..value.node_modules/state-ref/dist/index.d.ts..value// BAD
const age = stateRef.john.age;
// GOOD
const age = stateRef.john.age.value;
// BAD - accessing .value outside callback won't track
const externalRef = watch();
watch((ref) => {
console.log(externalRef.count.value); // NOT tracked
});
// GOOD - use the callback's ref parameter
watch((ref) => {
console.log(ref.count.value); // Tracked
});
const controller = new AbortController();
watch((ref) => {
console.log(ref.value);
return controller.signal;
});
controller.abort(); // Unsubscribe
import { createStore } from 'state-ref';
const watch = createStore({ count: 0, name: 'John' });
watch((ref, isFirst) => {
console.log('Count changed:', ref.count.value);
});
const ref = watch();
ref.count.value = 10; // Triggers subscription
import { createStore } from 'state-ref';
import { connectReact } from '@stateref/connect-react';
const watch = createStore({ age: 20 });
export const useStore = connectReact(watch);
// In component
function Component() {
const { age } = useStore();
return <button onClick={() => age.value++}>{age.value}</button>;
}
import { createStoreManualSync } from 'state-ref';
const { watch, updateRef, sync } = createStoreManualSync({ count: 0 });
export const increment = () => {
updateRef.count.value += 1;
sync(); // Notify subscribers
};
import { createStore, createStoreManualSync, combineWatch, createComputed } from 'state-ref'import { lens, copyable, cloneDeep } from 'state-ref'import { connectReact } from '@stateref/connect-react'import { connectPreact } from '@stateref/connect-preact'import { connectVue } from '@stateref/connect-vue'import { connectSvelte } from '@stateref/connect-svelte'import { connectSolid } from '@stateref/connect-solid'Use createStore for reactive state, access via .value, subscribe with watch(callback). Dependencies are tracked automatically inside callbacks. Use framework connectors for UI integration. For Flux patterns, use createStoreManualSync. Combine watches with combineWatch or derive computed values with createComputed.