import { Handle } from "../handle" ; import { useImperativeMethods } from "./imperative" ; import { callInstanceMethod } from "./use_method" ; 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  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  Handle an Element that has method `methodName`. In
 * the case that `provider` is `null`, then `defaultVal` will be returned.
 *
 *  param methodName param defaultVal public export function useMethodFrom ( provider , methodName , defaultVal ? ) { useImperativeMethods ( ( ) => ( { [ methodName ] : ( ... args ) => provider ? callInstanceMethod ( provider , defaultVal , methodName , ... args ) : defaultVal } ) ) ; }