-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Promisify stop()? #1076
Comments
Absolutely - the functions with only callbacks add substantial weirdness to building anything on top of it. (Block.get and Block.put are two others that I have to promisify in my code). |
@haadcode sounds good! Seems that we missed that one. Wanna submit that as a PR? |
@mitra42 just noticed that indeed block.get and block.put are not promisified, wanna add a PR with that? https://github.com/ipfs/js-ipfs/blob/master/src/core/components/block.js#L11-L15 |
All we are doing is
Then call
as part of the workaround to the bug in #1049 Anyway ... I haven't done any PRs for IPFS because given all the multiple repositories etc I have zero confidence in finding accurate docs to do the full cycle - clone; edit; test; submit PR, especially not to do something that breaks other code elsewhere in IPFS. |
PR for promisifying stop is here #1082. cc @diasdavid |
@mitra42 @diasdavid I went ahead and PRed the promisified block functions here #1085. We also need updated tests from ipfs-inactive/interface-js-ipfs-core#170 to merge it. |
We currently return from
stop()
with a callback.In order to stop IPFS properly, we write:
I find myself often preferring to use Promises and more recently await. As per IPFS api functions, we return a Promise (or callback) and I find it confusing that
stop()
is only callback.If we returned a Promise, we would write:
I'd like to propose we promisify the stop function.
We would keep the original callback in addition to returning a Promise, same as we do for API functions and the start() function.
How does everyone feel about this?
I'd be happy to PR this, but this would be a great task for first contributors if someone wants to work on it!
The text was updated successfully, but these errors were encountered: