tokizo
(tokizo)
October 30, 2023, 5:00am
1
Observation was proposed in swift-evolution and I thought it was added as a Swift language feature, but Apple's documentation describes it as a Framework and I am confused.
Isn't Observation a Swift language feature? Is it possible to use it on non-Apple platforms such as Ubuntu?
# Observation
* Proposal: [SE-0395](0395-observability.md)
* Authors: [Philippe Hausler](https://github.com/phausler), [Nate Cook](https://github.com/natecook1000)
* Review Manager: [Ben Cohen](https://github.com/airspeedswift)
* Status: **Implemented (Swift 5.9)**
* Review: [(pitch)](https://forums.swift.org/t/pitch-observation-revised/63757) [(first review)](https://forums.swift.org/t/se-0395-observability/64342/) [(second review)](https://forums.swift.org/t/second-review-se-0395-observability/65261/) [(acceptance)](https://forums.swift.org/t/accepted-with-revision-se-0395-observability/66760)
#### Changes
* Version 1: [Initial pitch](https://forums.swift.org/t/pitch-observation/62051)
* Version 2: Previously Observation registered observers directly to `Observable`, the new approach registers observers to an `Observable` via a `ObservationTransactionModel`. These models control the "edge" of where the change is emitted. They are the responsible component for notifying the observers of events. This allows the observers to focus on just the event and not worry about "leading" or "trailing" (will/did) "edges" of the signal. Additionally the pitch was shifted from the type wrapper feature over to the more appropriate macro features.
* Version 3: The `Observer` protocol and `addObserver(_:)` method are gone in favor of providing async sequences of changes and transactions.
* Version 4: In order to support observation for subclasses and to provide space to address design question around the asynchronous `values(for:)` and `changes(for:)` methods, the proposal now focuses on an `Observable` marker protocol and the `withTracking(_:changes:)` function.
#### Suggested Reading
* [Expression Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0382-expression-macros.md)
* [Attached Macros](https://github.com/apple/swift-evolution/blob/main/proposals/0389-attached-macros.md)
This file has been truncated. show original
Karl
(👑🦆)
October 30, 2023, 2:59pm
2
Correct, it is perfectly usable on non-Apple platforms. I don't know if I'd call it a "language feature"; it's a core library/part of the standard library.
Apple's docs use the word "framework" basically as a synonym for "(dynamic) library". It's just the word they use. Even the Swift standard library is described as a "framework":
As are their JS libraries
3 Likes
tokizo
(tokizo)
October 31, 2023, 12:36am
3
I was puzzled by the word "framework", but now I know that I don't have to be confined to it. Thank you!