tanstack-vue-store-skilld
БесплатноБез исполняемых скриптовНе проверенVue adapter for TanStack Store, a framework agnostic type-safe store. ALWAYS use when writing code importing "@tanstack/vue-store" in a Vue app. Covers the…
от skilld-dev★ 188 звёзд на GitHubОб этом скилле
@tanstack/[email protected]
Vue adapter for TanStack Store. Exact core dependency: @tanstack/[email protected] (package.json:41). src/index.ts:1 re-exports the whole core, so Vue apps import everything from @tanstack/vue-store alone.
Quick start
import { createStore, createAtom, shallow, useAtom, useSelector } from '@tanstack/vue-store'
// Module scope: create once, import anywhere
const counter = createStore({ count: 0 })
const countAtom = createAtom(0)
// Inside <script setup>
const count = useSelector(counter, (s) => s.count) // slice
const pair = useSelector(counter, (s) => ({ n: s.count }), { compare: shallow }) // object slice
const [n, setN] = useAtom(countAtom) // read + write
setN((prev) => prev + 1)
Read refs in templates as {{ count }}, in script as count.value.
Hooks (this package's own exports)
| Hook | Signature | Use |
|---|---|---|
useSelector |
(source, selector?, options?) => Readonly<Ref<TSelected>> |
Primary read hook. Store, atom, or any { get, subscribe } source. Omit the selector to subscribe to the whole value. |
useAtom |
(atom, options?) => [Readonly<Ref<TValue>>, atom.set] |
Read plus write for one writable atom. The setter takes a value or an updater function (src/useAtom.ts:20-27). |
_useStore |
(store, selector, options?) => [selected, actions or setState] |
Experimental read+write tuple. The selector argument is required (src/_useStore.ts:30). Returns store.actions when the store has an actions factory, else store.setState (src/_useStore.ts:37-38). |
useStore |
deprecated | Alias for useSelector. Third argument is a bare compare function, not an options object (src/useStore.ts:14-23). Prefer useSelector. |
options is UseSelectorOptions: { compare?: (a, b) => boolean } (src/useSelector.ts:4-6).
Details, behavior notes, and pitfalls: Vue hooks reference
Rules that prevent bugs
- Default compare is strict
===(src/useSelector.ts:15-17). When the selector builds a fresh object or array, pass{ compare: shallow }or the ref updates on every notification. Primitive selectors need no custom compare. - Call the hooks inside component setup or another effect scope.
useSelectorunsubscribes viaonScopeDispose(src/useSelector.ts:54-56); outside a scope, cleanup never runs. - Returned refs are
readonly. Write throughstore.setState,atom.set, storeactions, or the second tuple element ofuseAtom/_useStore. - Keep selectors cheap. The selector runs on every notification of the source (
src/useSelector.ts:46-52); move expensive computation into a derivedcreateStore. - Do not import
createStoreContextfrom this package. The 0.11.0 release notes list it, but the 0.11.1 source exports onlyuseSelector,useAtom,useStore,_useStoreplus the core re-export (src/index.ts,dist/index.d.ts). See release 0.11.0.
Core re-exports from @tanstack/store
createStore(initialValue)->Store<T>;createStore((prev?) => T)->ReadonlyStore<T>(derived);createStore(initialValue, actionsFactory)->Store<T, TActions>with typedstore.actions.Store:stategetter,get(),setState(updater),subscribe(observerOrFn)returning{ unsubscribe }, boundactions.ReadonlyStoreomitssetStateandactions.createAtom(initialValue)-> writableAtom<T>;createAtom(fn)-> computedReadonlyAtom<T>.AtomOptions.comparecontrols change detection.createAsyncAtom(() => Promise<T>)->ReadonlyAtomof a{ status }discriminated union:'pending' | 'done' | 'error'.batch(fn)groups updates into one notification cycle;flush()drains pending effects.shallow(a, b)comparesObject.is, then Map and Set contents, Date timestamps, and own keys including symbols.toObserver()normalizes callbacks or RxJS-style observers forsubscribe.- Types:
Observer,Subscription,Subscribable,Readable,Atom,ReadonlyAtom,AtomOptions,StoreActionMap,StoreActionsFactory, and others.
Full surface with cautions: core API reference
Best practices
- Use
useSelector, never the deprecateduseStore, for new code (src/useSelector.ts:39). - Define stores in plain modules outside components. This is the documented sharing pattern (Vue quick start).
- Select fine-grained slices. The component re-renders only when the selected value changes.
- Write state through
store.setState((prev) => next)updater functions; updates are immutable. - Group multiple updates in
batch(() => { ... })so subscribers notify once with the final state. - Derive with
createStore(() => ...); derived stores recompute when dependencies change, andprevaccumulates valu
Установить tanstack-vue-store-skilld в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл tanstack-vue-store-skilld?
Vue adapter for TanStack Store, a framework agnostic type-safe store. ALWAYS use when writing code importing "@tanstack/vue-store" in a Vue app. Covers the useSelector, useAtom, useStore (deprecated), and _useStore hooks, the re-exported @tanstack/store core API (createStore, createAtom, createAsyncAtom, batch, flush, shallow), debugging, best practices, and migration between @tanstack/vue-store versions.
Как установить скилл tanstack-vue-store-skilld?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл tanstack-vue-store-skilld запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic