CommandHandlerFactory
Builds a fresh set of CommandHandlers.
A factory rather than a ready-made array because CommandHandlerComponent registers the same handlers against several menu surfaces, and a handler carries per-registration state (its active-file provider, its plugin name, and whatever a subclass records in CommandHandler.onRegistered) — so every surface needs its own instances.
Returning shared instances (() => [handler1Singleton, handler2Singleton]) reintroduces exactly the bug the factory exists to avoid, so it is not merely discouraged: CommandHandler.onRegistered throws on the second registration of an instance. CommandHandlerComponent.registerCommandHandlers awaits it, so that throw rejects the caller’s promise instead of degrading into a wrong context menu.
Import:
import type { CommandHandlerFactory } from 'obsidian-dev-utils/obsidian/command-handlers/command-handler-component';Signature:
export type CommandHandlerFactorySignature:
type CommandHandlerFactory = () => CommandHandler[]Type: () => CommandHandler[]