make lsp better

This commit is contained in:
Dax Raad
2025-06-06 17:20:01 -04:00
parent b32cb2b932
commit d6afebf22a
9 changed files with 38 additions and 21 deletions

View File

@@ -78,6 +78,18 @@ export namespace Bus {
return raw(def.type, callback)
}
export function once<Definition extends EventDefinition>(
def: Definition,
callback: (event: {
type: Definition["type"]
properties: z.infer<Definition["properties"]>
}) => "done" | undefined,
) {
const unsub = subscribe(def, (event) => {
if (callback(event)) unsub()
})
}
export function subscribeAll(callback: (event: any) => void) {
return raw("*", callback)
}