-
Notifications
You must be signed in to change notification settings - Fork 1.2k
emit event once initialised #1058
Comments
This is incorrect regarding the
This outputs the following for me:
However, I would expect |
Ah, I think I misunderstood a tiny bit. You're saying that if the repo is already initiralized, the |
@victorbjelkholm yes, that's the problem. If the node happens to be offline, the |
Made a PR to address this that goes down the path of correcting the |
@pgte I just spent a bunch of time staring at all the bootstrapping code to document the constructor options and it looks to me like var IPFS = require('ipfs');
var node = new IPFS();
node.on('ready', () => {
console.log('READY!!!!!');
node.id().then(id => console.log('Peer Info:', id));
}); Am I misunderstanding what you’re getting at? (Seems important since these new event docs would be wrong if there’s a non-error case where it doesn’t emit.) |
I now see that I should have added a test case, since the behaviour I can no longer reproduce the behaviour I think was witnessing. (I think this may related to the Anyway, the point here is: The |
Looking at
|
Would passing start:false to the constructor and then waiting for the ready event be what you’re looking for? |
Type:
Enhancement
Severity:
Very Low
Description:
I want to support better offline use cases. I need the peerId to be able to start working locally, without needing for Swarm, Bitswap or Pubsub to consider themselves ready.
AFAIK, right now there is no event that tells me this.
init
is only emitted if the repo needs initialising.start
andready
are only emitted once the network layer is ready, which may not happen in my case.Right now I'm polling the IPFS node for the
_peerInfo
property, but I would like to have a better alternative.I would like to have an event that tells me once the peerId is known.
Steps to reproduce the error:
N/A
The text was updated successfully, but these errors were encountered: