weasel API - v0.8.0
    Preparing search index...

    Interface ActionsRegistryExperimental

    Imperative API exposed by useActionsRegistry().

    interface ActionsRegistry {
        begin(
            id: string,
            params?: Record<string, unknown>,
        ): UiOngoingControl | null;
        list(): readonly Action[];
        register(action: Action): () => void;
        setDepRegistry(r: DepRegistry | null): void;
        setDispatcher(d: Dispatcher | null): void;
        subscribe(listener: () => void): () => void;
        trigger(id: string, params?: Record<string, unknown>): boolean;
        unregister(id: string): void;
    }
    Index

    Methods

    • Experimental

      Start an ongoing action driven by UI (color picker, opacity slider). Returns a control object with update(params) and end(reason).

      Returns null if no dispatcher is wired into this registry, the action is unknown, or its invoker is not ongoing.

      See Dispatcher.beginUiOngoing for full semantics including auto-commit when a prior UI handle for the same action is in flight.

      Parameters

      • id: string
      • Optionalparams: Record<string, unknown>

      Returns UiOngoingControl | null

    • Experimental

      Wire a DepRegistry into the registry so trigger() / begin() can resolve action deps even when this provider is mounted ABOVE the dep registry (e.g. a consumer's root <ActionsProvider> reused by SceneCanvas's ActionsProviderIfRoot). Takes precedence over the dep registry read from context at the provider's own level. Call with null to detach.

      Parameters

      Returns void

    • Experimental

      Subscribe to registry mutations. The callback fires after any register/unregister that changes the version. Returns an unsubscribe function. Designed for useSyncExternalStore-driven surfaces (e.g. <ActionBar> in @weasel-js/ui) that need to re-render when the action set changes.

      Parameters

      • listener: () => void

      Returns () => void

    • Experimental

      Fire an immediate-invoker action by id. The optional params arg is forwarded to ImmediateInvoker.run as its second argument — use it for parametric actions (e.g. trigger('tool.activate', { toolId: 'rect' })). Ongoing-invoker actions are not reachable from trigger.

      Parameters

      • id: string
      • Optionalparams: Record<string, unknown>

      Returns boolean