[Second review] SE-0395: Observability

I just read through both review threads as well as the proposal. I'm generally +1, and I think value observation is very important for the language.

(TLDR: Please add a way to be notified when there are both some observers and no observers as a Future Direction.)

That being said, as best I can tell, there is currently no way for an Observable thing to know whether it is being observed or not.

I feel that this is very useful missing functionality, and the same concern I believe was raised in the initial review thread: SE-0395: Observability - #25 by Jon_Shier

Consider this use-case for such information:

@Observable
class Camera {
    
    // Not shown, but this is set with the most recent sample buffer.
    var latestSample: CMSampleBuffer? = nil
    
    func start() {
        // This turns the camera on.
        // If **somebody** is observing `latestSample`, the camera should turn on.
    }
    
    func stop() {
        // This turns the camera off.
        // If **nobody** is observing `latestSample`, the camera should turn off, to save power and resources.
    }
}
2 Likes