import * as React from 'react' ; import { DependencyIdentifier , Injector , LookUp , Quantity , RediError } from '@wendellhu/redi' ; import { RediContext } from './reactContext' ; class HooksNotInRediContextError extends RediError { constructor ( ) { super ( 'Using dependency injection outside of a RediContext.' ) ; } } export function useInjector ( ) { const injectionContext = React . useContext ( RediContext ) ; if ( ! injectionContext . injector ) { throw new HooksNotInRediContextError ( ) ; } return injectionContext . injector ; } export function useDependency < T > ( id , lookUp ? ) ; export function useDependency < T > ( id , quantity , lookUp ? ) ; export function useDependency < T > ( id , quantity , lookUp ? ) ; export function useDependency < T > ( id , quantity , lookUp ? ) ; export function useDependency < T > ( id , quantity , lookUp ? ) ; export function useDependency < T > ( id , quantity ? , lookUp ? ) ; export function useDependency < T > ( id , quantityOrLookUp ? , lookUp ? ) { const injector = useInjector ( ) ; return injector . get < T > ( id , quantityOrLookUp , lookUp ) ; }