Skip to content

Commit

Permalink
Timer+Oneshot: Return nil in the case of a timer with interval .never.
Browse files Browse the repository at this point in the history
NOTE: This is an API change, sorry.
  • Loading branch information
mickeyl committed Mar 22, 2023
1 parent 9d2b24f commit d924738
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ extension Timer {

/// Returns a ``Timer``, scheduled to fire exactly once after the specified `interval`.
/// If you're not supplying a ``RunLoop`` argument, we're using the one for the current ``Thread``.
public static func CC_oneShot(interval: DispatchTimeInterval, runloop: RunLoop = .current, mode: RunLoop.Mode = .common, block: @escaping @Sendable (Timer) -> Void) -> Timer {

public static func CC_oneShot(interval: DispatchTimeInterval, runloop: RunLoop = .current, mode: RunLoop.Mode = .common, block: @escaping @Sendable (Timer) -> Void) -> Timer? {
guard interval != .never else { return nil }
let timer = Timer(fire: Date() + interval.CC_timeInterval, interval: 0, repeats: false, block: block)
runloop.add(timer, forMode: mode)
return timer
Expand Down

0 comments on commit d924738

Please sign in to comment.