import { useObjectRef } from '@cloudbeaver/core-blocks' ; import { useService } from '@cloudbeaver/core-di' ; import type { NavNode } from './EntityTypes' ; import { NavNodeInfoResource } from './NavNodeInfoResource' ; interface IUseNodeHook { navNodeId : string ; node : NavNode | undefined ; isLoading : ( ) => boolean ; isLoaded : ( ) => boolean ; isOutdated : ( ) => boolean ; } const bindActions = [ 'isLoading' , 'isLoaded' , 'isOutdated' ] ; export function useNode ( navNodeId ) { const navNodeInfoResource = useService ( NavNodeInfoResource ) ; const node = navNodeInfoResource . get ( navNodeId ) ; return useObjectRef < IUseNodeHook > ( ( ) => ( { navNodeId , node , isLoading ( ) { return navNodeInfoResource . isDataLoading ( this . navNodeId ) ; } , isLoaded ( ) { return navNodeInfoResource . isLoaded ( this . navNodeId ) ; } , isOutdated ( ) { return navNodeInfoResource . isOutdated ( this . navNodeId ) ; } , } ) , { navNodeId , node , } , bindActions ) ; }