Skip to main content

observable_object

Function observable_object 

Source
pub fn observable_object() -> &'static Conformance
Expand description

An ObservableObject conformance on Foundation.JSONDecoder.

Three requirements, and the protocol has defaults for two of them: the associated ObjectWillChangePublisher and its Publisher conformance both come from the constrained extension where that type is ObservableObjectPublisher. Only the getter has to be supplied, and it forwards to Combine’s own default — so what this builds is the same table extension JSONDecoder: ObservableObject {} compiles to, which is what lets the parity reference declare exactly that and dump the same value.

The object this hangs on used to be ImageRenderer<AnyView>, the one class in SwiftUI that already conforms. That worked, but nothing could check it: reflecting into a live ImageRenderer faults, so the three modifiers taking an ObservableObject had no parity case at all. A JSONDecoder dumps in two lines.