From 3e89d2998588f8e35c524e523ba2ee853f0f6475 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Mon, 20 Apr 2026 11:31:17 +0200 Subject: refactor: restructure files to their domains, new preview overlay system, and dep graph --- apps/web/src/lib/actions/registry.ts | 63 ------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 apps/web/src/lib/actions/registry.ts (limited to 'apps/web/src/lib/actions/registry.ts') diff --git a/apps/web/src/lib/actions/registry.ts b/apps/web/src/lib/actions/registry.ts deleted file mode 100644 index e69b3b9f..00000000 --- a/apps/web/src/lib/actions/registry.ts +++ /dev/null @@ -1,63 +0,0 @@ -import type { - TAction, - TActionFunc, - TActionWithArgs, - TActionWithOptionalArgs, - TActionArgsMap, - TArgOfAction, - TInvocationTrigger, -} from "./types"; - -type ActionHandler = (arg: unknown, trigger?: TInvocationTrigger) => void; -const boundActions: Partial> = {}; - -export function bindAction( - action: A, - handler: TActionFunc, -) { - const handlers = boundActions[action]; - const typedHandler = handler as ActionHandler; - if (handlers) { - handlers.push(typedHandler); - } else { - boundActions[action] = [typedHandler]; - } -} - -export function unbindAction( - action: A, - handler: TActionFunc, -) { - const handlers = boundActions[action]; - if (!handlers) return; - - const typedHandler = handler as ActionHandler; - boundActions[action] = handlers.filter((h) => h !== typedHandler); - - if (boundActions[action]?.length === 0) { - delete boundActions[action]; - } -} - -type InvokeActionFunc = { - ( - action: TActionWithOptionalArgs, - args?: undefined, - trigger?: TInvocationTrigger, - ): void; - ( - action: A, - args: TActionArgsMap[A], - trigger?: TInvocationTrigger, - ): void; -}; - -export const invokeAction: InvokeActionFunc = ( - action: A, - args?: TArgOfAction, - trigger?: TInvocationTrigger, -) => { - boundActions[action]?.forEach((handler) => { - handler(args, trigger); - }); -}; -- cgit v1.3.1