Skip to content

Commit

Permalink
SwiftLint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tunous committed Apr 24, 2022
1 parent 095f4b8 commit 27070b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Expand Up @@ -8,7 +8,7 @@ let package = Package(
products: [
.library(
name: "DebouncedOnChange",
targets: ["DebouncedOnChange"]),
targets: ["DebouncedOnChange"])
],
dependencies: [
],
Expand All @@ -18,6 +18,6 @@ let package = Package(
dependencies: []),
.testTarget(
name: "DebouncedOnChangeTests",
dependencies: ["DebouncedOnChange"]),
dependencies: ["DebouncedOnChange"])
]
)
10 changes: 5 additions & 5 deletions Sources/DebouncedOnChange/DebouncedChangeViewModifier.swift
Expand Up @@ -2,12 +2,12 @@ import SwiftUI

extension View {

/// Adds a modifier for this view that fires an action only when a time interval in seconds represented by `debounceTime`
/// elapses between value changes.
/// Adds a modifier for this view that fires an action only when a time interval in seconds represented by
/// `debounceTime` elapses between value changes.
///
/// Each time the value changes before `debounceTime` passes, the previous action will be cancelled and the next action
/// will be scheduled to run after that time passes again. This mean that the action will only execute after changes to the value
/// stay unmodified for the specified `debounceTime` in seconds.
/// Each time the value changes before `debounceTime` passes, the previous action will be cancelled and the next
/// action /// will be scheduled to run after that time passes again. This mean that the action will only execute
/// after changes to the value /// stay unmodified for the specified `debounceTime` in seconds.
///
/// - Parameters:
/// - value: The value to check against when determining whether to run the closure.
Expand Down
8 changes: 6 additions & 2 deletions Sources/DebouncedOnChange/Task+Delayed.swift
Expand Up @@ -4,14 +4,18 @@ extension Task {

/// Asynchronously runs the given `operation` in its own task after the specified number of `seconds`.
///
/// The operation will be executed after specified number of `seconds` passes. You can cancel the task earlier for the operation to be skipped.
/// The operation will be executed after specified number of `seconds` passes. You can cancel the task earlier
/// for the operation to be skipped.
///
/// - Parameters:
/// - time: Delay time in seconds.
/// - operation: The operation to execute.
/// - Returns: Handle to the task which can be cancelled.
@discardableResult
public static func delayed(seconds: TimeInterval, operation: @escaping @Sendable () async -> Void) -> Self where Success == Void, Failure == Never {
public static func delayed(
seconds: TimeInterval,
operation: @escaping @Sendable () async -> Void
) -> Self where Success == Void, Failure == Never {
Self {
do {
try await Task<Never, Never>.sleep(nanoseconds: UInt64(seconds * 1_000_000_000))
Expand Down
2 changes: 1 addition & 1 deletion Tests/DebouncedOnChangeTests/DelayedTaskTests.swift
Expand Up @@ -13,6 +13,6 @@ final class DelayedTaskTest: XCTestCase {
}

wait(for: [negativeExpectation], timeout: 0.1)
wait(for: [positiveExpectation], timeout: 0.11)
wait(for: [positiveExpectation], timeout: 0.15)
}
}

0 comments on commit 27070b6

Please sign in to comment.