Polling With Combine’s dataTaskPublisher

Hi All,
having extensively searched Combine articles related to dataTaskPublisher, I’m still unsure how to approach this.

For example: Processing URL Session Data Task Results with Combine.

I would like to periodically call a URL, e.g. every minute. That is to refresh with the latest data. Options that spring to mind are:
  1. Use Timer.TimerPublisher to create the dataTaskPublisher every minute.

  2. Use Timer.TimerPublisher and dataTaskPublisher with Publishers.CombineLatest.

What would be the most elegant solution that is in accordance with - and makes full use of - the Combine framework?

Many thanks!



Follow up on the above that I tried option 2. This worked in the sense that the subscription was received every minute according to the timer. This can be see in the Date output below.

However, this did not cause the dataTaskPublisher to re-run. So the bytes shown are from the original request that ran once only.

Code Block
(2020-12-29 15:05:30 +0000, 61631 bytes) combined
(2020-12-29 15:05:33 +0000, 61631 bytes) combined
(2020-12-29 15:05:36 +0000, 61631 bytes) combined
(2020-12-29 15:05:39 +0000, 61631 bytes) combined
(2020-12-29 15:05:42 +0000, 61631 bytes) combined

Polling With Combine’s dataTaskPublisher
 
 
Q