mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2026-03-13 08:41:05 +08:00
2.6 KiB
2.6 KiB
RFC: src Simplification and Reactive Attr Events
- Status: Draft
- Target release: v8 minor
- Scope:
/srcruntime internals and docs
Goals
- Improve maintainability by reducing
src/ECharts.tsresponsibilities. - Keep public API stable: no new props, no removed exports.
- Make attrs-based event bindings reactive by default.
- Preserve smart-update semantics while improving implementation clarity.
Non-goals
- Introducing breaking API changes.
- Adding new runtime dependencies.
- Changing build output structure.
Decisions
- Keep only event-reactivity logic in
src/core/events.ts; move option/lifecycle flow back toECharts.tsfor readability. - Keep
ECharts.tsas the primary, explicit runtime flow. - Do not add a
reactive-eventsswitch. - Do not add
VChartExposedexport in this iteration. - Prefer straightforward implementation over speculative abstraction.
- Internal module APIs are not compatibility-bound and can be refactored with callsites together.
Core Refactor
- New
src/core/events.ts- Reactive chart/zr listener binding with diff + cleanup.
- Reactive native listener projection for render attrs.
- Option patch + smart-update flow remains in
src/ECharts.ts. - Chart init/cleanup and unmount disposal flow remains in
src/ECharts.ts.
Implementation Principle
For callback slots and internal runtime logic, prioritize direct and explicit code paths:
- avoid descriptor/compiler-style layers unless they reduce concrete complexity;
- keep parsing and application logic close to where it is used;
- use named shared helpers only when they remove repetition without adding indirection.
Behavior Change
Attrs listeners now update reactively:
on<Event>onZr:<event>onNative:<event>
Template syntax and runtime method signatures remain unchanged.
Risks and Controls
- Listener leaks when attrs update frequently.
- Control: per-key binding table and full unmount cleanup.
oncelisteners losing stable identity.- Control: store wrapped callback and unbind old callback before rebinding.
- Regression in setOption call patterns.
- Control: existing test suite + additional reactive listener tests.
Validation
Required checks:
pnpm lintpnpm typecheckpnpm test:nodepnpm test:browser
Additional tests:
- attrs chart handler switch A -> B
- attrs zr handler switch A -> B
- attrs native handler switch A -> B
- once handler replacement remains one-shot
Rollout
- Land
core/eventsand simplifyECharts.tsmain runtime flow. - Land update/slot/graphic simplifications.
- Land docs updates in both
README.mdandREADME.zh-Hans.md.