@adpt/core
Version:
AdaptJS core library
33 lines • 1.46 kB
TypeScript
import { Handle } from "../handle";
/**
* Hook to create an imperative method for a component which forwards calls
* to another component.
*
* @remarks
*
* Creates an imperative method named `methodName` on the component from which
* this hook is invoked, which calls the imperative method of the same
* name on the component instance referenced by `provider`.
*
* When this component's method `methodName` is called by another component,
* typically via {@link useMethod}, if `provider` does not reference a valid
* Element, `defaultVal` will be returned. If `methodName` does not exist on
* `provider` or is not a function, an error will be thrown. Otherwise, the
* provider Element's `methodName` method will be invoked and its return value
* returned to the caller.
*
* @param provider - a {@link Handle} an Element that has method `methodName`. In
* the case that `provider` is `null`, then `defaultVal` will be returned.
*
* @param methodName - The name that will be used for both the imperative
* method created on the invoking component and that will be invoked on the
* provider component.
*
* @param defaultVal - The value that will be returned if `provider` is null
* or if `provider` does not reference an Element in the DOM at the time of
* invocation.
*
* @public
*/
export declare function useMethodFrom(provider: Handle | null, methodName: string, defaultVal?: any): void;
//# sourceMappingURL=use_method_from.d.ts.map