@@ -25,8 +25,7 @@ import Data.Maybe (isJust)
2525-- @since 0.1.2
2626data DebounceSettings = DebounceSettings
2727 { debounceFreq :: Int
28− -- ^ Microseconds lag required between subsequence calls to the debounced
29− -- action.
28+ -- ^ Length of the debounce timeout period in microseconds.
3029 --
3130 -- Default: 1 second (1000000)
3231 --
@@ -48,18 +47,22 @@ data DebounceSettings = DebounceSettings
4847 -- @since 0.1.6
4948 }
5049
51−-- | Setting to control whether the action happens at the leading or trailing
50+-- | Setting to control whether the action happens at the leading and/or trailing
5251-- edge of the timeout.
5352--
5453-- @since 0.1.6
5554data DebounceEdge =
5655 Leading
57− -- ^ The action will either be performed immediately, or after the current cooldown period has expired.
58− | Trailing
59− -- ^ The action will be performed at the end of the current cooldown period.
56+ -- ^ Perform the action immediately, and then begin a cooldown period.
57+ -- If trigger happens again during the cooldown, wait until the end of the cooldown and then
58+ -- perform the action again /plus/ enter a new cooldown period.
6059 | LeadingAndTrailing
61− -- ^ The action is performed on the leading edge. It's also performed on the trailing edge if
62− -- the debounced function was invoked again during the cooldown.
60+ -- ^ Perform the action immediately, and then begin a cooldown period.
61+ -- If trigger happens again during the cooldown, wait until the end of the cooldown and then
62+ -- perform the action again but /do not/ enter a new cooldown period.
63+ | Trailing
64+ -- ^ Start a cooldown period and perform the action when the period ends. If another trigger
65+ -- happens during the cooldown, it has no effect.
6366 deriving (Show, Eq)
6467
6568mkDebounceInternal :: MVar () -> (Int -> IO ()) -> DebounceSettings -> IO (IO ())