diff --git a/TIFoundationUtils/Sources/TITimer/Sources/TITimer/Protocols/ITimer.swift b/TIFoundationUtils/Sources/TITimer/Sources/TITimer/Protocols/ITimer.swift index 17757062..7482795b 100644 --- a/TIFoundationUtils/Sources/TITimer/Sources/TITimer/Protocols/ITimer.swift +++ b/TIFoundationUtils/Sources/TITimer/Sources/TITimer/Protocols/ITimer.swift @@ -36,4 +36,10 @@ public protocol ITimer: Invalidatable { // Запустить работу таймера func start(with interval: TimeInterval) + + // Приостановить работу таймера + func pause() + + // Возобновить работу таймера + func resume() } diff --git a/TIFoundationUtils/Sources/TITimer/Sources/TITimer/TITimer.swift b/TIFoundationUtils/Sources/TITimer/Sources/TITimer/TITimer.swift index 90ca49b8..9505065e 100644 --- a/TIFoundationUtils/Sources/TITimer/Sources/TITimer/TITimer.swift +++ b/TIFoundationUtils/Sources/TITimer/Sources/TITimer/TITimer.swift @@ -79,10 +79,18 @@ public final class TITimer: ITimer { } public func pause() { + guard isRunning else { + return + } + invalidate() } public func resume() { + guard !isRunning else { + return + } + createTimer(with: interval) }