1.4 KiB
1.4 KiB
Frontend Lifecycle Conventions
Last updated: April 10, 2026
Vue component lifecycle
- Vue apps are created via
ui/vue/createVueApp.jswith Pinia store injection. - Components use
onMounted/onUnmountedfor DOM setup/teardown. - Event listeners added in
onMountedmust be removed inonUnmounted. - Pinia stores are the single source of truth for UI state.
Imperative runtime lifecycle
panelRuntime.jsmanages the top-level panel init/destroy cycle.- Feature modules (viewer, DnD, grid) expose
init()/destroy()orstart()/stop(). - The bootstrap sequence is:
bootstrap.jsinitializes the app contextpanelRuntime.jssets up the panel shell- Vue apps mount into panel slots
- Feature runtimes activate via events or direct calls
Teardown rules
- Every
addEventListenermust have a matchingremoveEventListeneron destroy. - Every
setInterval/setTimeoutmust be cleared on destroy. - Pinia store subscriptions are auto-cleaned when the Vue app unmounts.
- Custom event buses (
events.js) listeners must be unsubscribed explicitly.
Bridge conventions
comfyApiBridge.js: wraps ComfyUI API calls. Never call ComfyUI API directly from Vue components.panelStateBridge.js: syncs Pinia panel store with legacy imperative consumers. Will be removed when all consumers migrate to Vue.- New bridges should be avoided. Prefer Pinia stores or composables for new features.