-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
BREAKING CHANGE: All places in the API that used callbacks are now replaced with async/await
Sorry I meant to request changes 😂 I do approve, but just needs some minor tweaks! |
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.
Great @dirkmc !
Just left a comment regarding the listener.close
. Other than that, can you please update the API
on the README?
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.
Awesome! :D
Just noticed a minor thing
- `listener.listen(multiaddr, [callback])` | ||
- `listener.getAddrs(callback)` | ||
- `listener.close([options])` | ||
- `<Promise> listener.listen(multiaddr)` |
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.
Perhaps this should be a follow up PR instead, but since we're doing a breaking change it might be worth making listen
support an array of multiaddrs now https://github.com/libp2p/interface-transport/issues/41.
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.
Makes sense... should listen
require an array, or should it also support single multiaddr?
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.
I think it makes sense for it to just support an array. In the majority of cases the switch is going to be handling the .listen
call, so most users shouldn't notice the change.
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.
I agree that we can leverage this breaking change and change the multiaddr
param to an array. Should we do this in a separate PR, but only release a new version of interface-transport
once that is done?
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.
@dirkmc I'm holding on the release until we've added the listening array support. Are you working on that? If not I can start it, just avoiding the potential duplicate effort :)
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.
@jacobheun please go ahead - I have some other things going on at the moment so only able to snatch a bit of time here and there to work
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.
This looks good. One thing I would recommend changing are the trailing semicolons to leading semicolons.
listener.on('connection', async (conn) => {
// ...
});
(async () => {
// ...
})()
vs
listener.on('connection', async (conn) => {
// ...
})
;(async () => {
// ...
})()
The main reasoning being clarity. It's easier to reason that the leading semicolon belongs to that block and has the purpose of breaking up statements that would otherwise clash. Trailing commas are easier to misinterpret as being unneeded and subsequently removed.
Linting is smart enough to recognize this as not being an extra comma, but it would be easy for a human to accidentally remove it. Since we have no local test suite for this, that can be a rather annoying mistake to discover after a release.
You're right that's clearer. Fixed |
Since this PR was created @dirkmc and I talked about It's not strictly necessary, but I feel like it is a more intuitive API. @jacobheun is there some strong counterpoint to this? Secondly, I've altered |
I am in favor of waiting to return the active connection or erroring. With the ability to abort we really have everything we need and I agree it's more intuitive.
We should comply with the standard and add |
I add a |
I think the standard error code is 'ABORT_ERR': |
Ah, ok cool, I'll update Also, I just realised interface-transport/src/dial-test.js Line 59 in b30ee5f
|
BREAKING CHANGE: All places in the API that used callbacks are now replaced with async/await