import { Controller } from "stimulus" ; import { useMixin } from "./create_mixin" ; export function useMutationObserver ( controller , element , handler , options ) { handler = handler . bind ( controller ) ; let observer = new MutationObserver ( handler ) ; let setup = ( ) => observer . observe ( element , options ) ; let teardown = ( ) => observer . disconnect ( ) ; useMixin ( controller , setup , teardown ) ; return teardown ; }