paramikojs icon indicating copy to clipboard operation
paramikojs copied to clipboard

Use promises

Open kousu opened this issue 9 years ago • 1 comments

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.

kousu avatar Sep 23 '14 05:09 kousu

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!

mimecuvalo avatar Sep 25 '14 23:09 mimecuvalo