-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Remove ready event from basic usage #1762
Comments
I'd personally love to see this happen! 👍I think adding/changing what is suggested here would improve the usability and readability a ton (=2 loc). We had a discussion about it in the past in #1083 (see the different proposal for the API), but as you said @mikeal, things have changed now with using promises everywhere. Thanks for bringing it up again! ❤️ |
@mikeal As a frequent user of js-ipfs I also think something like this is really necessary — thanks for bringing this up! I would like, though, to make a distinction between creating and starting, and would like to make Because in some user-land packages we can be using IPFS node instances that we haven't created ourselves, we don't really know the start state, and simply doing something like this to ensure the node is started would help a lot on reducing the complexity of some processes: // a) starts or,
// b) if starting, returns when started or
// c) if started, returns immediately
await ipfs.start() Also, I think we should decide between calling the state Also, I think Nonetheless, the user could still ensure it's started by doing |
@pgte I ran into this just the other day calling I agree that it's confusing to have these two states, |
@mikeal that would be very helpful, (much alike a lot of node.js database clients where it queues operations or queries while not started). One potential problem with this is that multiple operations or queries could fail if starting fails. But I guess users could always wait for |
I don't think I would have had this idea had I not written this so many times in the
If |
Looking through the code on this and we'll need to do this in stages.
For step 2, we'll want to have a discussion about whether or not we want to do this before the big async function refactor or after. |
I am happy to look at this over the holidays! :) |
Now that we've started going down the "promises everywhere" rabbit hole it should be possible to remove waiting for the ready event from the default usage.
There's a few different ways we could go about this. Off the top of my head I think it would be nice to have a property on the object that is a promise that is resolved when ready.
And we could create a convenience method called
create()
that did this automatically.Thoughts?
The text was updated successfully, but these errors were encountered: