Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Stream Muxer should be allowed to return a promise #287

Closed
MarcoPolo opened this issue Sep 19, 2022 · 1 comment
Closed

Stream Muxer should be allowed to return a promise #287

MarcoPolo opened this issue Sep 19, 2022 · 1 comment
Labels
need/triage Needs initial labeling and prioritization

Comments

@MarcoPolo
Copy link
Contributor

diff --git a/packages/interface-stream-muxer/src/index.ts b/packages/interface-stream-muxer/src/index.ts
index 6ad19dd..a0efad2 100644
--- a/packages/interface-stream-muxer/src/index.ts
+++ b/packages/interface-stream-muxer/src/index.ts
@@ -18,7 +18,7 @@ export interface StreamMuxer extends Duplex<Uint8Array> {
    * Initiate a new stream with the given name. If no name is
    * provided, the id of the stream will be used.
    */
-  newStream: (name?: string) => Stream
+  newStream: (name?: string) => Stream | Promise<Stream>
 
   /**
    * Close or abort all tracked streams and stop the muxer

Sometimes a stream muxer needs to do some async work before it can return a new stream (as is the case with webtransport). The current implementation already calls newStream from an async function, so it wouldn't be a big change. In fact, the connection interface already returns a Promise<Stream> when a user calls newStream(...), so this is inline with that async context.

@MarcoPolo MarcoPolo added the need/triage Needs initial labeling and prioritization label Sep 19, 2022
@mpetrunic mpetrunic transferred this issue from libp2p/js-libp2p Sep 20, 2022
@MarcoPolo MarcoPolo linked a pull request Sep 27, 2022 that will close this issue
@mpetrunic
Copy link
Member

closed via #290

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants