reatom
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReatom
Reatom
Use this skill when implementing or explaining Reatom v1001. Treat REFERENCE.md as the canonical API reference bundled with this skill.
当你需要实现或讲解Reatom v1001时使用本技能。将REFERENCE.md视为与本技能绑定的权威API参考文档。
How to use
使用方法
- Read the sections of REFERENCE.md that match the task — do not load generic React/Solid/Vue state patterns when they conflict with the reference.
- Follow existing code in the touched package or example for naming, file layout, and extension style.
- For deep async flows (,
wrap,withAsyncData, sampling, Suspense), switch to thewithAbortskill.reatom-async - For (native DOM JSX, mount, props, css prop), switch to the
@reatom/jsxskill.reatom-jsx - For pull requests, reviews, or skeptic validation of agent output, switch to the skill.
reatom-review
- 阅读REFERENCE.md中与任务匹配的章节——当通用React/Solid/Vue状态模式与参考文档冲突时,请勿使用这些通用模式。
- 遵循所修改包或示例中的现有代码,保持命名、文件结构和扩展风格一致。
- 对于复杂异步流程(、
wrap、withAsyncData、采样、Suspense),请切换至withAbort技能。reatom-async - 对于(原生DOM JSX、挂载、props、css属性),请切换至
@reatom/jsx技能。reatom-jsx - 对于拉取请求、代码评审或验证Agent输出的合理性,请切换至技能。
reatom-review
Section map
章节映射
Use this map to open only the relevant parts of REFERENCE.md:
| Topic | Section |
|---|---|
| Atoms, computed, action, effect, extend | Core primitives and mental model |
| Queries and mutations | withAsync |
| Async context after await / callbacks | wrap rules |
| Collections, boolean, route helpers | Primitives quick usage |
| Nested reactive fields | Atomization |
| Subscribe error callback | Subscribe error listener |
| Logging, log.label, log.state | Full SPA example (logging setup) |
| Hooks, connect/disconnect, lazy work | Lifecycle and extension hooks |
| DOM / external events | Event sampling and orchestration |
| Hot derivations | Memoization: memo and memoKey |
| Fields and validation | Forms: base usage and reactive validation |
| SPA routes and loaders | Routing |
| Search params, storage | URL sync and persistence helpers |
| React Suspense integration | Suspense notes |
| Batched updates | Transactions notes |
| Tests and SSR | SSR and testing |
| Upgrades from older Reatom | v3 migration highlights |
Deeper recipes and adapter docs live on v1001.reatom.dev under and .
/docs/handbook/*/docs/reference/*使用此映射仅打开REFERENCE.md中的相关部分:
| 主题 | 章节 |
|---|---|
| Atoms、computed、action、effect、extend | 核心原语与心智模型 |
| 查询与变更 | withAsync |
| await/回调后的异步上下文 | wrap规则 |
| 集合、布尔值、路由助手 | 原语快速使用 |
| 嵌套响应式字段 | 原子化(Atomization) |
| 订阅错误回调 | 订阅错误监听器 |
| Logging、log.label、log.state | 完整SPA示例(日志设置) |
| Hooks、connect/disconnect、延迟任务 | 生命周期与扩展Hooks |
| DOM/外部事件 | 事件采样与编排 |
| 热派生 | 记忆化:memo和memoKey |
| 字段与验证 | 表单:基础用法与响应式验证 |
| SPA路由与加载器 | 路由 |
| 搜索参数、存储 | URL同步与持久化助手 |
| React Suspense集成 | Suspense说明 |
| 批量更新 | 事务说明 |
| 测试与SSR | SSR与测试 |
| 从旧版Reatom升级 | v3迁移要点 |
Implementation defaults
实现默认规则
- Named atoms, actions, computed values, and effects; factory names use the prefix.
reatom* - Reads: zero-arg call. Writes: .
.set(...) - Idempotent reads: .
computed(async () => ...).extend(withAsyncData(...)) - Commands/mutations: .
action(async () => ...).extend(withAsync(...)) - Async boundaries that leave the Reatom frame: ; external callbacks: pass
await wrap(promise).wrap(fn) - Derived state in ; side effects in
computedwith explicit lifetime (route loader, init action, or mount scope — not unscoped module effects for feature work).effect - Forms (fields, validation, submit) through /
reatomForminstead of hand-rolled per-field atoms and submit actions.reatomField - Route data through loaders; navigation with
reatomRoute, links with.go(...)..path(...)
When the reference and local examples disagree, prefer the reference and fix the example if it is wrong.
- 命名Atoms、actions、computed值和effects;工厂函数名称使用前缀。
reatom* - 读取:无参数调用。写入:。
.set(...) - 幂等读取:。
computed(async () => ...).extend(withAsyncData(...)) - 命令/变更:。
action(async () => ...).extend(withAsync(...)) - 超出Reatom框架的异步边界:;外部回调:传递
await wrap(promise)。wrap(fn) - 派生状态放在中;副作用放在
computed中并明确生命周期(路由加载器、初始化动作或挂载作用域——功能开发中不要使用无作用域的模块effects)。effect - 表单(字段、验证、提交)通过/
reatomForm实现,而非手动为每个字段创建atoms和提交actions。reatomField - 路由数据通过加载器获取;使用
reatomRoute导航,使用.go(...)生成链接。.path(...)
当参考文档与本地示例不一致时,优先遵循参考文档,若示例有误则修复示例。