Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Sources/Repeat/Debouncer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ open class Debouncer {
public typealias Callback = (() -> Void)

/// Delay interval
public let delay: Repeater.Interval
private (set) public var delay: Repeater.Interval

/// Callback to activate
public var callback: Callback?
Expand All @@ -58,7 +58,15 @@ open class Debouncer {

/// Call debouncer to start the callback after the delayed time.
/// Multiple calls will ignore the older calls and overwrite the firing time.
public func call() {
///
/// - Parameters:
/// - newDelay: New delay interval
public func call(newDelay: Repeater.Interval? = nil) {

if let newDelay = newDelay {
self.delay = newDelay
}

if self.timer == nil {
self.timer = Repeater.once(after: self.delay, { _ in
guard let callback = self.callback else {
Expand Down