import creepyface , { Consumer , Point } from 'creepyface' ; import { useMemo } from 'react' ; const name = 'imperative' ; let lastPoint = null ; let pointConsumer = null ; creepyface . registerPointProvider ( name , ( consumer ) => { const timeout = setTimeout ( ( ) => consumer ( lastPoint ) , 0 ) ; pointConsumer = consumer ; return ( ) => { clearTimeout ( timeout ) ; pointConsumer = null ; } ; } ) ; const setPoint = ( point ) => { lastPoint = point ; pointConsumer ?. ( point ) ; } ; export default function useImperativePointProvider ( ) { return useMemo ( ( ) => [ name , setPoint ] as const , [ ] ) ; }