refactor: keep the word cloud shape tap as a stable member callback - #4680
Merged
xile611 merged 1 commit intoSep 14, 2026
Merged
Conversation
Follow-up to VisActor#4679. `hooks.afterRender` is declared as `SyncHook<[IStage]>`, so a tap already receives the stage it runs on — the same way `Stage` registers its own `constructor` tap. That removes the need to remember `{ stage, fn }` on the series: the callback is a member with a stable identity, it unregisters itself from the stage it is handed, and `release()` reaches the stage through `_option`, which is still alive before `super.release()` clears it. Drops the `_afterWordcloudShapeDrawTap` field and the `_removeAfterWordcloudShapeDrawTap` helper, and moves the tap name into a single module constant so registration and removal cannot drift apart. No behavior change: the existing word cloud tap tests still cover removal on release and the absence of duplicate registrations.
xile611
approved these changes
Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 This is a ...
🔗 Related issue link
Follow-up to #4679 (fix #4649).
🔗 Related PR link
#4679
🐞 Bugserver case id
💡 Background and solution
#4679 landed the word cloud shape tap lifecycle fix, but it kept a
{ stage, fn }record on the series so thatrelease()could still reach the stage after the fact:That record is unnecessary.
hooks.afterRenderis declared asSyncHook<[IStage]>, so a tap already receives the stage it runs on — the same signatureStageuses for its ownconstructortap (this.afterRender = stage => { ... }).So the callback can simply be a member with a stable identity:
The three places that need a stage each already have one:
stageargument the hook passes instagealready resolved inonLayoutFinishedrelease()this._option?.globalInstance?.getStage()—_optionis only cleared bysuper.release(), which runs afterA stable member identity is also exactly what
unTap(name, fn)wants, so thefnargument requested in the #4679 review is preserved: a stage hosting more than one word cloud series still only drops its own callback.This deletes the
_afterWordcloudShapeDrawTapfield and the_removeAfterWordcloudShapeDrawTaphelper, and moves the tap name into one module constant so registration and removal cannot drift apart.📝 Changelog
Internal refactor, no behavior change — no changelog entry (
"type": "none").☑️ Self-Check before Merge
Verified:
word-cloud-shape-release.test.ts(removal on release, no duplicate registration) and the two background cases inupdate-spec.test.tsall pass;tsc --noEmitclean; prettier clean.