Skip to main content

Function: subscribeWithValidatedCleanup()

subscribeWithValidatedCleanup(register: () => unknown, handlers: CleanupResolutionHandlers): Promise<() => void>

Defined in: src/services/utils/cleanupHandlers.ts:124

Registers a subscription and validates the resulting cleanup handler.

Parametersโ€‹

registerโ€‹

() => unknown

Function invoking the preload subscription and returning the cleanup candidate or a promise for one.

handlersโ€‹

CleanupResolutionHandlers

Hooks for invalid cleanup values and cleanup failures.

Returnsโ€‹

Promise<() => void>

Promise resolving to a normalized cleanup function.

Remarksโ€‹

The helper awaits the subscription result, passes it through resolveCleanupHandler, and returns the normalised cleanup callback. Services use this to guarantee symmetrical setup and teardown even when the preload bridge returns incorrect values.