⏰Timer
⭐️ 注意:Timer 屬於 Foundation 的類別
.onReceive()
accepts a publisher as its first parameter and a function to run as its second.
.onChange()
is called on the main thread. Avoid performing long-running tasks on the main thread. If you need to perform a long-running task in response to value
changing, you should dispatch to a background queue.
Because Timer.TimerPublisher
conforms to the ConnectablePublisher
protocol, it won’t produce elements until you explicitly connect to it. Do this by either calling connect()
, or using an autoconnect()
operator to connect automatically when a subscriber attaches.
Last updated
Was this helpful?