Understanding the return value of a Combine Subscriber’s receive() method

I have a Combine publisher that uses a CADisplayLink to send output (Void in this case) to a subscriber. To do that, I have this callback method:


@objc private func displayLinkFired(_: CADisplayLink) {
    let demand = self.subscriber.receive()
}


I have this publisher hooked up to a SwiftUI View that uses the onReceive() modifier to update some State when the DisplayLink fires. When the subscription is initially created, its demand value is unlimited, as I would expect. But in this method, the return value of receive(), stored in demand, is .max(0). Why is it .max(0) and not, as I would expect in this case, .unlimited?

You'll probably get more focused answers moving this thread to SwiftUI.


For my understand, could you show the context where displayLinkFired is called ?


Good luck.

Understanding the return value of a Combine Subscriber’s receive() method
 
 
Q