effectorjs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseEffectorJS Skill
EffectorJS 技能
Use this skill to produce deterministic, scope-safe Effector solutions for new features, refactors, and code reviews.
使用本技能为新功能、重构和代码评审生成确定性的、作用域安全的Effector解决方案。
Workflow
工作流程
- Classify the request:
- : create or extend stores/events/effects.
modeling - : replace anti-patterns with declarative flows.
refactor - : implement or debug scope-safe SSR.
ssr - : assess risks, regressions, and missing tests.
review - : move old patterns to modern v23+ safely.
legacy-migration
- Load only required references:
- Always start with .
references/core-patterns.md - Always load after core patterns to enforce plugin-backed best practices.
references/lint-derived-best-practices.md - Add when task touches app bootstrap, startup logic, initialization order, tests, scope, or SSR.
references/explicit-start.md - Add when task touches ordering,
references/computation-priority.md, sequencing, race-like behavior, or side effects placement.watch - Add when React/SSR/scope appears.
references/react-ssr-scope.md - Add when Solid integration appears.
references/solid-scope.md - Add when Vue integration appears.
references/vue-scope.md - Add when fixing or reviewing existing logic.
references/anti-patterns-and-fixes.md - Add when deprecated APIs/imports are present.
references/legacy-migration-map.md - End with for acceptance criteria.
references/checklists.md
- Build solution in this order:
- Model atomic stores and explicit events.
- Define explicit app start () and keep startup wiring declarative.
appStarted - Move side effects to effects.
- Connect units with first; use
samplefor effect composition.attach - Apply scope-first rules (,
fork) for tests, SPA bootstrap boundaries, and SSR.allSettled - For UI frameworks, use and correct provider wiring.
useUnit
- Produce output contract:
- Proposed model topology (stores/events/effects and responsibilities).
- Wiring snippets (,
sample,attachif needed).split - Scope/SSR notes when applicable.
- Lint-derived conformance notes for naming/dataflow/scope/react constraints.
- Test scenarios and acceptance checklist.
- 对请求进行分类:
- :创建或扩展stores/events/effects。
modeling - :用声明式流替换反模式。
refactor - :实现或调试作用域安全的SSR。
ssr - :评估风险、回归问题和缺失的测试。
review - :将旧模式安全迁移到现代v23+版本。
legacy-migration
- 仅加载必要的参考资料:
- 始终从开始。
references/core-patterns.md - 在核心模式之后,始终加载以强制执行基于插件的最佳实践。
references/lint-derived-best-practices.md - 当任务涉及应用启动、启动逻辑、初始化顺序、测试、作用域或SSR时,添加。
references/explicit-start.md - 当任务涉及执行顺序、、序列处理、类竞争行为或副作用放置时,添加
watch。references/computation-priority.md - 当涉及React/SSR/作用域时,添加。
references/react-ssr-scope.md - 当涉及Solid集成时,添加。
references/solid-scope.md - 当涉及Vue集成时,添加。
references/vue-scope.md - 当修复或评审现有逻辑时,添加。
references/anti-patterns-and-fixes.md - 当存在已弃用的API/导入时,添加。
references/legacy-migration-map.md - 最后加载作为验收标准。
references/checklists.md
- 按以下顺序构建解决方案:
- 建模原子化stores和显式events。
- 定义显式的应用启动()并保持启动连线为声明式。
appStarted - 将副作用迁移到effects中。
- 首先使用连接单元;使用
sample进行effect组合。attach - 对测试、SPA启动边界和SSR应用“作用域优先”规则(、
fork)。allSettled - 对于UI框架,使用和正确的提供者连线。
useUnit
- 生成输出约定:
- 提议的模型拓扑(stores/events/effects及其职责)。
- 连线代码片段(、
sample、必要时使用attach)。split - 适用时的作用域/SSR说明。
- 基于Lint的命名/数据流/作用域/React约束合规性说明。
- 测试场景和验收检查清单。
Defaults
默认规则
- Target Effector modern v23+.
- Treat deprecated/legacy patterns as migration targets, not defaults.
- Prefer minimal, explicit unit graph over clever abstractions.
- Treat lint-derived practices from as baseline constraints.
eslint-plugin-effector - Use glossary-consistent terminology in explanations and reviews.
- 目标为现代Effector v23+版本。
- 将已弃用/旧版模式视为迁移目标,而非默认选项。
- 优先选择最小化、显式的单元图,而非复杂的抽象。
- 将衍生的Lint实践视为基线约束。
eslint-plugin-effector - 在解释和评审中使用与术语表一致的术语。
Glossary Alignment (Effector)
术语表对齐(Effector)
- : include
Unit,Store,Event,Effect,Domain.Scope - : only
Common unit,Store,Event(reactive update sources for many APIs).Effect - : read-only store built from other stores (
Derived store,map, effect-derived stores likecombine)..pending - constraints: do not mutate directly and do not use as
Derived storeintarget.sample - :
Reducerhandlers must return next state;store.on(...)or same reference (undefined) means no store update.=== - : side effects/debug observability only; watcher return value is ignored.
Watcher - : treat unsubscribe handlers as infrastructure concern; avoid manual subscription management in business logic.
Subscription - : pure functions (
Purity,map, transform callbacks) must not imperatively call events/effects..on - : namespace for units;
Domainhooks are acceptable for infra-level cross-cutting concerns (logging/instrumentation), not business orchestration.onCreate*
- :包括
Unit、Store、Event、Effect、Domain。Scope - :仅指
Common unit、Store、Event(许多API的响应式更新源)。Effect - :基于其他store构建的只读store(
Derived store、map、effect衍生的store如combine)。.pending - 约束:不得直接修改,也不得在
Derived store中作为sample使用。target - :
Reducer处理函数必须返回下一个状态;返回store.on(...)或相同引用(undefined)表示不更新store。=== - :仅用于副作用/调试可观测性;忽略watcher的返回值。
Watcher - :将取消订阅处理视为基础设施相关事项;避免在业务逻辑中手动管理订阅。
Subscription - :纯函数(
Purity、map、转换回调)不得命令式调用events/effects。.on - :单元的命名空间;
Domain钩子可用于基础设施层面的横切关注点(日志/监控),而非业务编排。onCreate*
Guardrails
防护规则
- Do not place business logic in .
watch - Prefer over
sample/forwardfor orchestration.guard - Respect computation priority: keep /
mappure and avoid side effects in pure computation stages..on - Do not call events/effects imperatively from effect bodies when declarative wiring can express the flow.
- Do not use for business dataflow; pass state through
$store.getState()source.sample - Do not use derived stores as in
target; target writable units/events/effects only.sample - Keep /
sampleoptions in semantic order:guard.clock -> source -> filter -> fn -> target - Avoid ambiguous usage (no simultaneous result assignment and explicit
target).target - Avoid duplicate units in /
clockarrays and duplicatesourcehandlers for one store-event pair..on - Do not use /
samplewithout runtime effect (must have target or captured result).guard - Do not create units dynamically at runtime.
- Keep naming explicit (,
$store,eventHappened).someFx - In React, bind callable units with ; avoid raw event/effect usage in JSX handlers.
useUnit
- 不得在中放置业务逻辑。
watch - 编排时优先使用而非
sample/forward。guard - 遵循计算优先级:保持/
map的纯函数特性,避免在纯计算阶段产生副作用。.on - 当声明式连线可以表达流时,不得从effect体中命令式调用events/effects。
- 不得使用进行业务数据流处理;通过
$store.getState()的source传递状态。sample - 不得将衍生store作为中的
sample;仅以可写单元/events/effects为目标。target - 保持/
sample选项的语义顺序:guard。clock -> source -> filter -> fn -> target - 避免模糊的使用(不得同时进行结果赋值和显式指定
target)。target - 避免在/
clock数组中出现重复单元,以及同一个store-event对存在重复的source处理函数。.on - 不得使用没有运行时效果的/
sample(必须有target或捕获的结果)。guard - 不得在运行时动态创建单元。
- 保持命名明确(、
$store、eventHappened)。someFx - 在React中,使用绑定可调用单元;避免在JSX处理函数中直接使用原始的event/effect。
useUnit
Legacy Handling
遗留代码处理
If legacy code is present:
- Keep behavior unchanged first.
- Mark legacy section explicitly.
- Propose modern replacement with a migration-safe diff strategy.
- Add tests that prove parity before cleanup.
如果存在遗留代码:
- 首先保持行为不变。
- 显式标记遗留代码部分。
- 提出带有安全迁移差异策略的现代替代方案。
- 在清理前添加证明功能一致性的测试。