import { getValue } from '@glimmer/tracking/primitives/cache' ; import { invokeHelper } from '@ember/helper' ; import { DEFAULT_THUNK , normalizeThunk } from './utils' ; import type { Cache , Thunk } from './types' ; import type { helper as emberFunctionHelper } from '@ember/component/helper' ; import type Helper from '@ember/component/helper' ; export function useHelper ( context , helper , thunk = DEFAULT_THUNK ) { let resource ; return { get value ( ) : unknown { if ( ! resource ) { resource = invokeHelper ( context , helper , ( ) => { return normalizeThunk ( thunk ) ; } ) as Cache < unknown > ; } return getValue < unknown > ( resource ) ! ; } , } ; }