mimecuvalo / paramikojs

port of the paramiko library from python→javascript
http://fireftp.net
Other
91 stars 26 forks source link

Use promises #7

Open kousu opened 10 years ago

kousu commented 10 years ago

This is a feature request. Well, more of a stylistic request.

Paramikojs performs network processes in an entirely async environment. This leads to lots of callbacks everywhere. A lot of this would shortened for readability by the use of promises. The key feature is that the promises/A+ spec declares that promises chain, which means individual steps of an asynchronous process do not need to be hardcoded in what to call next. I recently solved another networking problem--implementing SOCKS5--elegantly with promises. If you put your thumb over all the .then()s, that _connect() reads like a synchronous subroutine.

I can't speak for everyone, but I would find the API would be easier to use if I could ask for promises instead of needing to pass in callbacks.

This would require a large overhaul of some code that you are probably a bit tired of, but I wanted to bring the option to your attention.

mimecuvalo commented 10 years ago

Yeah, +1 for promises. When I first started writing paramikojs it was only just starting to be talked about in conjunction with JS.

I'll keep this in mind going forward too!