import { observable } from '@goldfishjs/reactive' ; export interface IRequestingCounterFunction < R > { ( ) : Promise < R > | R ; } param fn export default function RequestingCounter < R > ( fn ) { const counter = observable ( { value : 0 } ) ; const wrappedFn = async ( ) => { counter . value += 1 ; try { const result = await fn ( ) ; return result ; } catch ( e ) { throw e ; } finally { counter . value -= 1 ; } } ; return [ wrappedFn , counter ] ; }