You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's seems very weird to me that WebSdkApi.connect() resolves before the agent is actually available, so we have to do this (from the README):
// We just started up, so we're still connecting. Let's wait for isAvailable == true
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
while (!client.agent.isAvailable) {
await sleep(50)
// ATTN! This is not production quality code. In a real UI, you should register an event handler for `client.on('agent-state')`
// and store the agent state in reactive state so that your components can just branch on isAvailable.
}
Instead connect() should just not resolve the promise until the agent is available (or preferably signUp() should not resolve until the agent is available #102).
The text was updated successfully, but these errors were encountered:
Hey @mattyg - The code in that example is very bad. I recently decided to just take it out of the docs, as despite the warning, I've seen it replicated many times when someone has implemented holo in their happ (understandably, it's in the README).
But that's slightly orthogonal to your suggestion.
One reason for returning immediately from .connect is to let the UI stay responsive. Rather than blocking on the .connect call, the UI subscribes to the agent-state event, and updates it's state accordingly as that gets updated.
One reason for returning immediately from .connect is to let the UI stay responsive. Rather than blocking on the .connect call, the UI subscribes to the agent-state event, and updates it's state accordingly as that gets updated.
But in practice you're going to be calling .connect in a function and not waiting for that function, i.e.:
It's seems very weird to me that
WebSdkApi.connect()
resolves before the agent is actually available, so we have to do this (from the README):Instead
connect()
should just not resolve the promise until the agent is available (or preferablysignUp()
should not resolve until the agent is available #102).The text was updated successfully, but these errors were encountered: