Comments (12)
I've created a repo with a README here and will keep it updated based on our discussion here
https://github.com/hoodiehq/hoodie-client-connection
from hoodie-client.
Really nice thoughts here. Thank you for writing this down.
After giving it some thought, I think the new API is more conclusive and feels easier to use.
Would it be possible to add a method to try to reconnect manually or is this made by connection.check
?
My use case here:
App checks connection just every 5-10 minutes to save battery and requests. But after editing the data locally, the user might want to upload the data asap. Does it make sense?
re: questions:
- I love the idea to allow to set defaults for intervals / timeouts, because it looks like it's a feature people are asking for again and again. Saving in the app config could be an idea?
- I'd love that. Gives more insight and freedom. Always up for that.
- -1 on that, but maybe just not seeing the use case here.
from hoodie-client.
App checks connection just every 5-10 minutes to save battery and requests. But after editing the data locally, the user might want to upload the data asap. Does it make sense?
hoodie.connection
is independent from the store sync. If you change something locally, it gets pushed immediately by default. hoodie.connection.check({interval: 10 * 60 * 1000})
would only check if you are still connected every 10 minutes.
If a request fails from hoodie.store
, I'd immediately run hoodie.connection.check()
to see if it's an issue with CouchDB, or if the entire server cannot be reached.
Does that make sense?
from hoodie-client.
So basically hoodie.connection.check()
is for debugging? :)
from hoodie-client.
In a way, yeah. it's to manually check the connection
from hoodie-client.
Okay, cool :)
from hoodie-client.
Instead of hoodie.connection
, we could call it hoodie.connectionStatus
.
I can imagine that reading hoodie.connection
in code without context looks like it would be an open socket to the back-end, with the ability to emit and receive events in both directions.
The full API on hoodie
client being
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
, with the full API on hoodie
client being
hoodie.status.connected // undefined, true, false
hoodie.status.check(options)
hoodie.status.on(event, handler) // disconnected, reconnected
For sake of clarity, I tend towards hoodie.connectionStatus
. Any thoughts?
from hoodie-client.
I like the clarity of hoodie.connectionStatus
as well.
- What does
hoodie.connectionStatus.check(options)
return? - Does
undefined
fromhoodie.connectionStatus.ok
mean a connection has never been made?
from hoodie-client.
check() returns a promise, rejects with error, resolves with nothing, see docs on hoodie-client-connection
from hoodie-client.
And yes undefined
means connection has not yet been checked
from hoodie-client.
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
from hoodie-client.
We settled on an API now, we split up .check
with interval into .startChecking
/ .stopChecking
as suggested here: hoodiehq/hoodie-connection-status#13
from hoodie-client.
Related Issues (20)
- An in-range update of uglify-js is breaking the build 🚨 HOT 1
- 💯 test coverage HOT 1
- An in-range update of uglify-js is breaking the build 🚨 HOT 1
- after reconnecting, store does not resume sync HOT 6
- An in-range update of browserify is breaking the build 🚨 HOT 2
- Package hoodie-client for Bower HOT 7
- hoodie.account options are not applied HOT 4
- 'change' event no longer triggered after sign in / sign out HOT 1
- Compacting PouchDB HOT 3
- pass options to plugins
- An in-range update of pouchdb-adapter-http is breaking the build 🚨 HOT 4
- An in-range update of pouchdb-adapter-memory is breaking the build 🚨 HOT 4
- An in-range update of pouchdb-core is breaking the build 🚨 HOT 4
- An in-range update of pouchdb-replication is breaking the build 🚨 HOT 4
- Arguments ignored in custom events HOT 2
- An in-range update of @hoodie/store-client is breaking the build 🚨 HOT 2
- An in-range update of uglify-js is breaking the build 🚨 HOT 14
- Project still alive? HOT 5
- Offline multi-user authentication HOT 5
- Option to set database name respectively split data into multiple databases HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hoodie-client.