Skip to content

Commit 234aa6d

Browse files
committed
wip
1 parent 65449ee commit 234aa6d

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

Sources/AsyncTimer/AsyncTimer.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public enum AsyncTimerInfo: Sendable {
1818
}
1919

2020
/// A simple repeating timer that runs a task at a specified interval.
21-
final actor AsyncTimer {
21+
public final actor AsyncTimer {
2222
// MARK: - Properties
2323

2424
/// Repeating task handler
25-
typealias RepeatHandler = @Sendable () async -> Void
25+
public typealias RepeatHandler = @Sendable () async -> Void
2626

2727
/// Cancel handler
28-
typealias CancelHandler = @Sendable () async -> Void
28+
public typealias CancelHandler = @Sendable () async -> Void
2929

3030
/// The task that runs the repeating timer.
3131
private var task: Task<Void, Error>?
@@ -57,12 +57,12 @@ final actor AsyncTimer {
5757
/// - handler: The handler that is called when the timer fires.
5858
/// - cancelHandler: The handler that is called when the timer is cancelled.
5959
/// - Returns: A new `AsyncRepeatingTimer` instance.
60-
init(interval: TimeInterval,
61-
priority: TaskPriority = .medium,
62-
repeating: Bool = false,
63-
firesImmediately: Bool = true,
64-
handler: @escaping RepeatHandler,
65-
cancelHandler: CancelHandler? = nil)
60+
public init(interval: TimeInterval,
61+
priority: TaskPriority = .medium,
62+
repeating: Bool = false,
63+
firesImmediately: Bool = true,
64+
handler: @escaping RepeatHandler,
65+
cancelHandler: CancelHandler? = nil)
6666
{
6767
self.interval = interval
6868
self.priority = priority
@@ -74,7 +74,7 @@ final actor AsyncTimer {
7474

7575
/// Starts the timer.
7676
/// - Note: If the timer is already running, it will be stopped and restarted.
77-
func start() {
77+
public func start() {
7878
stop()
7979
task = Task(priority: priority) {
8080
guard repeating else {
@@ -100,22 +100,22 @@ final actor AsyncTimer {
100100
}
101101

102102
/// Stops the timer.
103-
func stop() {
103+
public func stop() {
104104
guard let task else { return }
105105
task.cancel()
106106
self.task = nil
107107
}
108108

109109
/// Restarts the timer.
110-
func restart() {
110+
public func restart() {
111111
stop()
112112
start()
113113
}
114114

115115
/// Modifies the interval of the timer.
116116
/// - Parameter newInterval: The new interval at which the timer should fire.
117117
/// - Note: This will also restart the timer.
118-
func setInterval(_ newInterval: TimeInterval) {
118+
public func setInterval(_ newInterval: TimeInterval) {
119119
interval = newInterval
120120
restart()
121121
}

0 commit comments

Comments
 (0)