waitForSession
- waitForSession()
Resolves as soon as a session becomes active – immediately, if one already is, or once a session event fires (see Events on the dcp/identity overview page) otherwise.
- Return type:
Promise<DistributiveSession>
Useful when some other part of your application calls login() (or logs in as a side effect of something else), and you just need to know once it’s done, without owning the login() call yourself.
Example
const identity = require('dcp/identity');
const session = await identity.waitForSession();
console.log('Session ready:', session.id);