registerComplete
The on-…-complete-* classes resolve their value to a function. registerComplete is the clean way to publish those functions without polluting the global scope.
js
import { registerComplete, initAnimations } from 'gclass-anims'
registerComplete('showToast', (el) => {
toast('animation finished on', el)
})
initAnimations()Resolution order
When an element carries e.g. on-spawn-complete-showToast, the engine looks up:
- the registry populated by
registerComplete(name, fn) - a global fallback:
window["showToast"]if it is a function
Registering before initAnimations() is safest, but not required - lookups happen at completion time, not wiring time. Returning the same fn you pass in makes inline registration ergonomic:onClick={registerComplete('x', fn)}