import { Reaction } from "mobx" ; param func param delay param name export function autorunThrottled ( func , delay , name ? ) { if ( ! name ) { name = "autorunThrottled" ; } let isScheduled = false , isStarted = false ; const r = new Reaction ( name , ( ) => { if ( ! isStarted ) { isStarted = true ; r . track ( func ) ; } else if ( ! isScheduled ) { isScheduled = true ; setTimeout ( ( ) => { isScheduled = false ; if ( ! r . isDisposed ) { r . track ( func ) ; } } , delay || 1 ) ; } } ) ; r . runReaction ( ) ; return r . getDisposer ( ) ; }