Core API Overview > @adpt/core > callFirstInstanceWithMethod
callFirstInstanceWithMethod() 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.
Search for the first built Element instance in the Handle chain of hand that implements method methodName and immediately execute it.
Signature:
export declare function callFirstInstanceWithMethod<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 that has method methodName. Otherwise, returns the default value def.
Remarks
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.