Skip to content

Conversation

@phausler
Copy link
Contributor

@phausler phausler commented Mar 5, 2025

This proposal contains a modification to the Observation module that adds a new type. This type is an AsyncSequence that produces values over time by tracking transactional changes to @Observable marked types.

Copy link
Member

@heckj heckj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixes a few grammar typos

`AsyncSequence` of values emitted from changes to a property on a given model
type. For example, DockKit provides `trackingStates` and Group Activities
provides `localParticipantStates`. These are much like other APIs that provide
`AsyncSequence` from a model type; they hand crafted to provide events from when
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`AsyncSequence` from a model type; they hand crafted to provide events from when
`AsyncSequence` from a model type; they are hand crafted to provide events from when

prime for the next call to the iterator's `next` method.

The closure has two other features that are important for common usage; firstly
the closure is typed-throws such that any access to that emission closure will
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the closure is typed-throws such that any access to that emission closure will
the closure uses typed-throws such that any access to that emission closure will

@rjmccall rjmccall added the LSG Contains topics under the domain of the Language Steering Group label Mar 17, 2025
@phausler
Copy link
Contributor Author

phausler commented Apr 2, 2025

@Jumhyn I added a new section for Behavioral Notes to describe in more detail what should be expected for the edge cases. There are obviously other combinations to be had; such as building around types that have atomic transitions etc. But in an effort to keep it under a "war and peace sized proposal" I opted for what I feel might be the more common appropriate uses.


Numerous frameworks in the Darwin SDKs provide APIs for accessing an
`AsyncSequence` of values emitted from changes to a property on a given model
type. For example, DockKit provides `trackingStates` and Group Activities
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that (AFAICT) the cited examples are closed source, it's not self-evident that they have semantics compatible with what's being proposed here. are you asserting that they do – i.e. these API could be re-implemented with the proposed Observed type? are there open source examples that could be used here instead?

…version for explicitly constructing Observed untilFinished
@Jumhyn Jumhyn merged commit c956aac into swiftlang:main Apr 11, 2025
phausler added a commit to swiftlang/swift that referenced this pull request Jun 10, 2025
…acked values over time (#79817)

This is an implementation for the feature
swiftlang/swift-evolution#2726
phausler added a commit to phausler/swift that referenced this pull request Jun 11, 2025
stephentyrone added a commit to swiftlang/swift that referenced this pull request Jun 12, 2025
…acked values over time (#79817) (#82197)

- **Explanation**:
This is an implementation for the feature
swiftlang/swift-evolution#2726
- **Scope**:
This is targeted specifically to the Observation module, no language or
runtime changes
- **Issues**:

- **Original PRs**:
#79817
- **Risk**:
Low
- **Testing**:
This was tested in external forms (which need to be merged in)
- **Reviewers**:

---------

Co-authored-by: Stephen Canon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LSG Contains topics under the domain of the Language Steering Group

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants