Thanks, I've submitted a pull request with 2 new examples that show off 2 of the bugs found during this review.
Example 5 demonstrates that values(of:)
and therefore total(of:)
don't cause an "access" that would establish an "observation". As you've already said, this one is easily fixed, and the example should start working as soon as it is.
Example 6 demonstrates that Sendable & Observable
guarantees that there are race conditions which can mean that an observer never receives the final progress update. This one is pretty fundamental to the approach. I think the easiest fix would be to further distinguish ProgressManager
and ProgressReporter
by removing Observable
from ProgressManager
, adding @MainActor
to ProgressReporter
, and ensuring that it only notifies observers of updates from its children on the main actor. But although that would solve SwiftUI's problem, I think it limits the usefulness of the system as a whole — it wouldn't then be appropriate for server workloads.