-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hoodie connection status API #6
Comments
I've created a repo with a README here and will keep it updated based on our discussion here |
Really nice thoughts here. Thank you for writing this down. Would it be possible to add a method to try to reconnect manually or is this made by re: questions:
|
If a request fails from Does that make sense? |
So basically |
In a way, yeah. it's to manually check the connection |
Okay, cool :) |
Instead of I can imagine that reading The full API on hoodie.connectionStatus.ok // undefined, true, false
hoodie.connectionStatus.check(options)
hoodie.connectionStatus.on(event, handler) // disconnected, reconnected Another alternative would be to call it hoodie.status.connected // undefined, true, false
hoodie.status.check(options)
hoodie.status.on(event, handler) // disconnected, reconnected For sake of clarity, I tend towards |
I like the clarity of
|
check() returns a promise, rejects with error, resolves with nothing, see docs on hoodie-client-connection |
And yes |
work in progress, see discussion at hoodiehq/hoodie-client#6
I settled on ConnectionStatus, it's implemented at https://github.com/hoodiehq/hoodie-client-connection-status. I'll leave the issue open, maybe we can farther streamline the API, it's easy to change before the release of 1.0 |
We settled on an API now, we split up |
Due to its offline-first nature, the Hoodie client should provide APIs to tell if connected to its back-end or not.
Current APIs
I never liked the fact that the logic is not contained in a namespace like
hoodie.store
&hoodie.account
, and thet.isConnected()
is a function.💡 New API
I've an idea for a new API but am not yet happy with it. What we need:
disconnected
event if request to check connection failed, pass meaningful errorreconnected
event if request to check connection succeeded when it failed beforehoodie.connection
Here's what my current idea looks like
Open questions (updated Oct 24):
We tend to yes, via config like
{connection: { check: { interval: 10000, timeout: 1000 }}}
API could look like
hoodie.connection.lastCheckedAt
Use case: I used my app months ago without internet connection. If we read out the last state my app would tell me that I'm offline and would trigger a
"reconnected"
event, which might be confusing. To avoid that, we can set a cache timeout after which the cache will be ignoredThe text was updated successfully, but these errors were encountered: