Core API Overview > @adpt/core > callNextInstanceWithMethod
callNextInstanceWithMethod() function
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Starting with the successor of hand
, search for a built Element instance in the handle chain that implements method methodName
and immediately execute it.
Signature:
export declare function callNextInstanceWithMethod<T = any>(hand: Handle, def: T, methodName: string, ...args: any[]): T;
Parameters
Parameter | Type | Description |
---|---|---|
hand | Handle | |
def | T | |
methodName | string | |
args | any[] |
Returns:
T
The return value of the called instance method if hand
is associated and there is an Element in the handle chain (other than hand
) that has method methodName
. Otherwise, returns the default value def
.
Remarks
If hand
is not associated with an Element, an error is thrown.
The exact check that is currently used when searching the handle chain is mounted Elements that have an instance method methodName
. Because only built Elements have an Element instance, this only selects Elements that are mounted and built and will not select Elements that have been replaced by a style sheet rule.