Files
jason5ng32andClaude Fable 5 4ae3646700 Feat(core): add the app command bus and route cross-component triggers through it
Events keep saying "this happened"; commands say "do this" — single owner,
dispatch resolves when the work finishes with the owner's result, reject
codes unavailable/timeout (bus) and auth/quota/input (owners, via
appCommandError). Homepage sections register ipinfo:refresh /
connectivity:run / webrtc:run / dnsleak:run / speedtest:toggle; keyboard
shortcuts, the refresh orchestrator, and Persona Check's dependency repair
dispatch instead of reaching through template refs, and Home.vue sheds the
test-section refs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 13:32:57 +08:00

14 lines
589 B
JavaScript

// Vue binding for the command bus (utils/app-commands.js): register a command
// owner for the life of the current component / effect scope. Registration
// happens at setup time so the command is dispatchable as soon as the owner
// exists; the scope's disposal unregisters it.
import { getCurrentScope, onScopeDispose } from 'vue';
import { registerAppCommand } from '../utils/app-commands.js';
export const useAppCommand = (name, handler) => {
const unregister = registerAppCommand(name, handler);
if (getCurrentScope()) onScopeDispose(unregister);
return unregister;
};