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

Replace LP2PReceiver.ontransport with LP2PQuicTransportListener #33

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

backkem
Copy link
Collaborator

@backkem backkem commented Dec 31, 2023

This PR writes out the last option mentioned in #32. LP2PReciever.ontransport is removed in favor of a LP2PQuicTransportListener object. This allows a QuicTransport to be created/accepted by both the LP2PReceiver and LP2PRequest. It also replaces the EventHandler with a ReadableStream as mentioned in #30.

Do we find this to be an improvement overall? The new code examples look reasonable to me. The downsides I see are:

  • LP2PQuicTransportListener is quite long.
  • You have to know about the LP2PQuicTransport and LP2PQuicTransportListener constructors in addition to LP2PReceiver and LP2PRequest.
  • There is a naming difference between LP2PReceiver and LP2PQuicTransportListener. However, that does reflect their different way of working.

One way to address these is to add shorthand helpers as existed in the original explainer, pseudo code example:

// Peer A
const listener = navigator.lp2p.listen( { /* ... */ } );

// Peer B
const transport = navigator.lp2p.connect( { /* ... */ } );

Preview | Diff

@backkem backkem requested a review from anssiko January 8, 2024 14:56
Copy link
Member

@anssiko anssiko left a comment

Choose a reason for hiding this comment

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

This looks good.

I support the idea of shorthand helpers to minimize conceptual weight for common use cases. It is OK for more advanced use cases to require a more involved API. The common things should be easy, advanced things possible (that is, need to refer to API docs). If we can already identify those common code paths we will do web developers a service by providing helpers.

@backkem backkem mentioned this pull request Jan 9, 2024
@backkem backkem merged commit d2f0148 into WICG:main Jan 9, 2024
2 checks passed
@backkem backkem deleted the transport-listener branch January 9, 2024 11:14
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.

2 participants