Type Method


Returns a publisher that repeatedly emits the current date on the given interval.


static func publish(every interval: TimeInterval, tolerance: TimeInterval? = nil, on runLoop: RunLoop, in mode: RunLoop.Mode, options: RunLoop.SchedulerOptions? = nil) -> Timer.TimerPublisher



The time interval on which to publish events. For example, a value of 0.5 publishes an event approximately every half-second.


The allowed timing variance when emitting events. Defaults to nil, which allows any variance.


The run loop on which the timer runs.


The run loop mode in which to run the timer.


Scheduler options passed to the timer. Defaults to nil.

Return Value

A publisher that repeatedly emits the current date on the given interval.


The return type, Timer.TimerPublisher, conforms to ConnectablePublisher, which means you must explicitly connect to the Timer publisher to begin publishing events. You can do this with a call to connect(), or by using autoconnect() to automatically connect when a subscriber attaches, as shown here:

cancellable = Timer.publish(every: 1, on: .main, in: .common)
    .sink() {
        print ("timer fired: \($0)")


Declaring Publisher Topography

typealias Timer.TimerPublisher.Output

The kind of values published by this publisher.

typealias Timer.TimerPublisher.Failure

The kind of errors this publisher might publish.

Creating a Timer Publisher

See Also

Firing Messages as a Combine Publisher

class Timer.TimerPublisher

A publisher that repeatedly emits the current date on a given interval.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software