@@ -83,22 +83,16 @@ mkDebounceInternal baton delayFn (DebounceSettings freq action edge) = do
8383 mask_ $ void $ forkIO $ forever $ do
8484 takeMVar baton
8585 case edge of
86− Leading -> ignoreExc action >> runDelay
87− Trailing -> runDelay
88−
89− return $ void $ tryPutMVar baton ()
90−
91− where runDelay = do
86+ Leading -> do
87+ ignoreExc action
9288 delayFn freq
89+ Trailing -> do
90+ delayFn freq
91+ -- Empty the baton of any other activations during the interval
92+ void $ tryTakeMVar baton
93+ ignoreExc action
9394
94− case edge of
95− Trailing -> do
96− -- Empty the baton of any other activations during the interval
97− void $ tryTakeMVar baton
98− ignoreExc action
99− Leading ->
100− -- We already fired at the beginning of the interval so do nothing
101− return ()
95+ return $ void $ tryPutMVar baton ()
10296
10397ignoreExc :: IO () -> IO ()
10498ignoreExc = handle $ \(_ :: SomeException) -> return ()