diff --git a/Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift b/Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift index 9f8b462..8fdec2e 100644 --- a/Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift +++ b/Sources/CornucopiaCore/Extensions/Timer/Timer+Oneshot.swift @@ -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