Spaces:
Paused
Paused
Download console/src/utils/skillChangeEvents.ts from mysticaldragon/HF: direct link, hf CLI and curl.
- Browser
- Download file 765 Bytes
-
https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/utils/skillChangeEvents.ts
- Command line
-
hf download hf://spaces/mysticaldragon/HF/console/src/utils/skillChangeEvents.ts
-
curl -L -o skillChangeEvents.ts https://huggingface.co/spaces/mysticaldragon/HF/resolve/main/console/src/utils/skillChangeEvents.ts
765 Bytes
| export interface SkillChangeDetail { | |
| agentId: string; | |
| } | |
| const SKILL_CHANGE_EVENT = "qwenpaw:skills-changed"; | |
| export function notifySkillChange(agentId: string): void { | |
| if (typeof window === "undefined") return; | |
| window.dispatchEvent( | |
| new CustomEvent<SkillChangeDetail>(SKILL_CHANGE_EVENT, { | |
| detail: { agentId }, | |
| }), | |
| ); | |
| } | |
| export function subscribeToSkillChanges( | |
| listener: (detail: SkillChangeDetail) => void, | |
| ): () => void { | |
| if (typeof window === "undefined") return () => undefined; | |
| const handleChange = (event: Event) => { | |
| listener((event as CustomEvent<SkillChangeDetail>).detail); | |
| }; | |
| window.addEventListener(SKILL_CHANGE_EVENT, handleChange); | |
| return () => window.removeEventListener(SKILL_CHANGE_EVENT, handleChange); | |
| } | |