Skip to content

MonkeyAroundComponentRegisterMethodPatchParams<$Object, MethodName>

Parameters passed to MonkeyAroundComponent#registerMethodPatch.

Import:

import type { MonkeyAroundComponentRegisterMethodPatchParams } from 'obsidian-dev-utils/obsidian/components/monkey-around-component';

Signature:

export interface MonkeyAroundComponentRegisterMethodPatchParams<$Object extends object, MethodName extends MethodKeys<$Object>>

Properties

PropertyTypeDescription
$object$ObjectThe object to patch.
methodNameMethodNameThe method name to patch.
once?booleanWhen true, the patch uninstalls itself the first time the patched method is invoked, restoring the original — so the interception happens exactly once. Existing callers that omit it are unaffected.
patchHandlerPatchHandlerFunction<$Object, MethodName>The patch handler function.
patchToken?symbolAn optional token to identify the patch.

The token is recorded against the method this patch INSTALLS, so the next patch of the same method detects it via hasPatchToken on its own originalMethod and can defer to this one. The patch that installs a token therefore never sees its own token — only the patches stacked on top of it do. Use a Symbol.for token to make the detection work across independently bundled copies of this library.

The token is dropped when this component unloads, so a later patch that had deferred takes over on its next call.
postPatchHandler?PostPatchHandlerFunction<$Object, MethodName>An optional post-patch handler function that runs after the patch is applied.