on master help sign in
Simplify runDelay/Trailing logic
commit260ba2a44254cdf7a18e013b08d0ab52826c9ff0 authorTom McLaughlin <pyro777@gmail.com> dateThu 4 Jul 2019, 13:58 (7 years ago) parent17f92cd
1 file changed+7−6
auto-update/Control/Debounce/Internal.hs+7−6
auto-update/Control/Debounce/Internal.hs+7−6
@@ -67,19 +67,20 @@ mkDebounceInternal baton delayFn (DebounceSettings freq action edge) = do
6767 mask_ $ void $ forkIO $ forever $ do
6868 takeMVar baton
6969 case edge of
70− Leading -> ignoreExc action >> runDelay False
71− LeadingAndTrailing -> ignoreExc action >> runDelay False
72− Trailing -> runDelay True
70+ Leading -> ignoreExc action >> runDelay
71+ LeadingAndTrailing -> ignoreExc action >> runDelay
72+ Trailing -> runDelay
7373
7474 return $ void $ tryPutMVar baton ()
7575
76− where runDelay hasDelayedInitialActivation = do
76+ where runDelay = do
7777 delayFn freq
7878
7979 case edge of
8080 Trailing -> do
81− firedDuringInterval <- isJust <$> tryTakeMVar baton
82− when (firedDuringInterval || hasDelayedInitialActivation) $ ignoreExc action
81+ -- Empty the baton of any other activations during the interval
82+ void $ tryTakeMVar baton
83+ ignoreExc action
8384 Leading ->
8485 -- We already fired at the beginning of the interval so do nothing
8586 return ()