-
Notifications
You must be signed in to change notification settings - Fork 91
refactor: switch to async iterators #183
Conversation
BREAKING CHANGE: Switch to using async/await and async iterators. The transport and connection interfaces have changed.
12af334 to
55fb9ad
Compare
7406a4a to
2397cf5
Compare
|
There is a bug for: |
0e0eef2 to
5cf568e
Compare
5cf568e to
2b6ecbe
Compare
477bec0 to
53870ec
Compare
src/socket-to-conn.js
Outdated
| socket.end(err => { | ||
| if (err) return reject(err) | ||
| maConn.timeline.close = Date.now() | ||
| resolve() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar issue to libp2p/js-libp2p-webrtc-direct#30 (comment) with the end and the close event code both getting called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed
9c92753 to
d024ed2
Compare
d024ed2 to
0633843
Compare
jacobheun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
BREAKING CHANGE: Switch to using async/await and async iterators. The transport and connection interfaces have changed.
In the context of ipfs/js-ipfs#1670
Depends on:
Interface Transport
dial(ma<Multiaddr>, [options<Object>]): Promise<Connection>Dial to a peer at the given multiaddr, returns a promise that is resolved when the connection has opened. Throws if connection error or any other error opening the connection, including if the connection is aborted.
The promise resolves to a
Connection(which is a duplex object) that can be used to communicate with the peer.Options
signal- anAbortSignalthat can be used to abort the dial. You can obtain one from anAbortControllercreateListener([options<Object>], [handler<Function<Connection>>]): ListenerCreate a new listener, where incoming connections are handled by
handler. The handler function is called for each new incoming connection. It is passed aConnection(which is a duplex object). Note the handler param is optional and can be registered later by listening for the 'connected' event.filter(mas<Multiaddr[]>): Multiaddr[]Filter the multiaddrs this transport can dial.
Events
listeningAfter the listener has started listening.
connectedFor every new connection. The event handler is passed a
Connection(which is a duplex object).closeAfter the listener has stopped listening.
Interface Listener
listen(): PromisegetAddrs(): Promise<Multiaddr[]>