<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Timer/publish(every:tolerance:on:in:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So7NSTimerC10FoundationE7publish5every9tolerance2on2in7optionsAbCE14TimerPublisherCSd_SdSgSo9NSRunLoopCSo0kL4ModeaAnCE16SchedulerOptionsVSgtFZ"
  },
  "title" : "publish(every:tolerance:on:in:options:)"
}
-->

# publish(every:tolerance:on:in:options:)

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
```

## Parameters

`interval`

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

`tolerance`

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

`runLoop`

The run loop on which the timer runs.

`mode`

The run loop mode in which to run the timer.

`options`

Scheduler options passed to the timer. Defaults to `nil`.

## Return Value

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

## Discussion

The return type, [`Timer.TimerPublisher`](/documentation/Foundation/Timer/TimerPublisher), conforms to <doc://com.apple.documentation/documentation/Combine/ConnectablePublisher>, which means you must explicitly connect to the [`Timer`](/documentation/Foundation/Timer) publisher to begin publishing events. You can do this with a call to <doc://com.apple.documentation/documentation/Combine/ConnectablePublisher/connect()>, or by using <doc://com.apple.documentation/documentation/Combine/ConnectablePublisher/autoconnect()> to automatically connect when a subscriber attaches, as shown here:

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

## Topics

### Declaring Publisher Topography

### Creating a Timer Publisher

[`init(interval:tolerance:runLoop:mode:options:)`](/documentation/Foundation/Timer/TimerPublisher/init(interval:tolerance:runLoop:mode:options:))

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



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)