forked from Mirrors/elk
fix: cleanup command when hot reload
This commit is contained in:
parent
17a15e2917
commit
335fc9f64b
1 changed files with 9 additions and 5 deletions
|
@ -175,9 +175,10 @@ export const useCommand = (cmd: CommandProvider) => {
|
||||||
|
|
||||||
registry.register(cmd)
|
registry.register(cmd)
|
||||||
|
|
||||||
onDeactivated(() => {
|
const cleanup = () => registry.remove(cmd)
|
||||||
registry.remove(cmd)
|
|
||||||
})
|
onDeactivated(cleanup)
|
||||||
|
tryOnScopeDispose(cleanup)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useCommands = (cmds: () => CommandProvider[]) => {
|
export const useCommands = (cmds: () => CommandProvider[]) => {
|
||||||
|
@ -192,9 +193,12 @@ export const useCommands = (cmds: () => CommandProvider[]) => {
|
||||||
registry.register(cmd)
|
registry.register(cmd)
|
||||||
}, { deep: true, immediate: true })
|
}, { deep: true, immediate: true })
|
||||||
|
|
||||||
onDeactivated(() => {
|
const cleanup = () => {
|
||||||
commands.value.forEach(cmd => registry.remove(cmd))
|
commands.value.forEach(cmd => registry.remove(cmd))
|
||||||
})
|
}
|
||||||
|
|
||||||
|
onDeactivated(cleanup)
|
||||||
|
tryOnScopeDispose(cleanup)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const provideGlobalCommands = () => {
|
export const provideGlobalCommands = () => {
|
||||||
|
|
Loading…
Reference in a new issue