The small preview component below is intended for <KeepAlive>. It subscribes to an external event channel and loads a card through a fake API. Behavior should be predictable on activation, deactivation, and when channelId changes.
channelId: string and enabled: boolean.enabled === true, it must subscribe to preview-bus by channelId.channelId changes, the stale request must be canceled and only data for the current channel should be shown.channelId must clear the card and must not start a request.fetchPreview(id) returns Promise<{ id: string; title: string; tags: string[] }>.channelId="alpha" and enabled=true.preview-bus and the response from fetchPreview("alpha").channelId to beta without unmounting the component.alpha response arriving later than the new beta response.<KeepAlive>, then activate it again.enabled=false, send an event to preview-bus for the current channel.channelId, only the beta card remains on screen.alpha response does not overwrite the current data.preview-bus do not change the screen.<script setup> and Composition APIUse line comments to explain the problem, its impact, the fix and how to test it.