Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an introduction and formatting for the combineLatest algorithm into a proposal. #177

Merged
merged 2 commits into from
Aug 4, 2022

Conversation

phausler
Copy link
Member

Read the full proposal here.

@tcldr
Copy link

tcldr commented Jul 17, 2022

Excited to see this included. One comment:

The Naming part of the proposal mentions "withLatestFrom" as alternative naming. However, this is a quite different algorithm. Unlike, say CombineLatest2, which takes publisher A and publisher B, and emits when either A or B updates, withLatestFrom only emits when B updates. This can be useful for getting a snapshot of a frequently emitting sequence, say accelerometer data, on the occurrence of an infrequently emitting sequence, say a screen tap. e.g:

for await (tap, acceleration) in screenTaps.withLatestFrom(accelerometer) {
    // do something only on screen tap, with last emitted data from accelerometer
}

I'd love to see a proposal for this operator, too.

Also, what is the home for discussions on evolution proposals for Swift Algorithms? I couldn't find a CombineLatest thread in the swift forums and I don't see any discussions on the Issues board. The package readme mentions GitHub or Swift Forums, but isn't specific.

@phausler
Copy link
Member Author

I haven't posted them to the forums yet; was planning on doing that Monday. Per an additional algorithm - that is definitely something we should talk about but I want to get through the stuff we have first and then discuss the others with a bit more dedicated focus. But if you want to take that on we can park that as a pitch until then and get it queued up as an item to cover.

@tcldr
Copy link

tcldr commented Jul 18, 2022

Lovely, makes sense. Thanks, Philippe.

@phausler
Copy link
Member Author

For those wanting to follow along and post feedback on the algorithm itself: https://forums.swift.org/t/swift-async-algorithms-proposal-combinelatest/59042

@twittemb
Copy link
Contributor

Excited to see this included. One comment:

The Naming part of the proposal mentions "withLatestFrom" as alternative naming. However, this is a quite different algorithm. Unlike, say CombineLatest2, which takes publisher A and publisher B, and emits when either A or B updates, withLatestFrom only emits when B updates. This can be useful for getting a snapshot of a frequently emitting sequence, say accelerometer data, on the occurrence of an infrequently emitting sequence, say a screen tap. e.g:

for await (tap, acceleration) in screenTaps.withLatestFrom(accelerometer) {
    // do something only on screen tap, with last emitted data from accelerometer
}

I'd love to see a proposal for this operator, too.

Also, what is the home for discussions on evolution proposals for Swift Algorithms? I couldn't find a CombineLatest thread in the swift forums and I don't see any discussions on the Issues board. The package readme mentions GitHub or Swift Forums, but isn't specific.

Hi,

If I may, there is already a proposal for withLatestFrom (temporarily named zipLatestFrom). The PR is here and the pitch is here

@twittemb
Copy link
Contributor

twittemb commented Jul 26, 2022

Hi @phausler

From what I can see, on the one hand the implementation of CombineLatest3 is just a shortcut on two CombineLatest2. On the other hand, the implementations of Merge3 and Zip3 are done from scratch. Why not reusing two Merge2 and Zip2 ? is there is performance overhead in doing this ?

Thanks.

@phausler phausler merged commit c0fdfdb into apple:main Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants