useCommand
CommandPalette
stable
Process-wide command palette registry. Uses module-scope state (not provide/inject) so commands can be registered from anywhere — feature code, plugins, background services — without coupling to a Vue tree. Two callers on the same module instance see the exact same reactive list.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
Entries are deduplicated by id at write time. Calling register() with the same id replaces the previous entry in place so the array length stays stable and watchers on length only see one mutation.
Interfaces consommées
ICommand
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- register
- Register a command. Returns an unregister() closure. When called inside a Vue effect scope, the entry is auto-unregistered on scope dispose (component unmount, route leave).
- unregister
- Drop the entry with the matching id. No-op if the id is unknown.
- commands
- Reactive read-only view of every registered command, deduplicated by id.
- open
- Open the global palette singleton.
- close
- Close the global palette singleton.
- isOpen
- Reactive open/close state of the global palette singleton.
Usage
Exemples
Extraits de code prêts à coller.
Register a command from a feature component
Open and close the palette programmatically