Giter Club home page Giter Club logo

Comments (12)

gr2m avatar gr2m commented on June 26, 2024

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.

zoepage avatar zoepage commented on June 26, 2024

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:

  1. 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?
  2. I'd love that. Gives more insight and freedom. Always up for that.
  3. -1 on that, but maybe just not seeing the use case here.

from hoodie-client.

gr2m avatar gr2m commented on June 26, 2024

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.

zoepage avatar zoepage commented on June 26, 2024

So basically hoodie.connection.check() is for debugging? :)

from hoodie-client.

gr2m avatar gr2m commented on June 26, 2024

In a way, yeah. it's to manually check the connection

from hoodie-client.

zoepage avatar zoepage commented on June 26, 2024

Okay, cool :)

from hoodie-client.

gr2m avatar gr2m commented on June 26, 2024

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.

HipsterBrown avatar HipsterBrown commented on June 26, 2024

I like the clarity of hoodie.connectionStatus as well.

  • What does hoodie.connectionStatus.check(options) return?
  • Does undefined from hoodie.connectionStatus.ok mean a connection has never been made?

from hoodie-client.

gr2m avatar gr2m commented on June 26, 2024

check() returns a promise, rejects with error, resolves with nothing, see docs on hoodie-client-connection

from hoodie-client.

gr2m avatar gr2m commented on June 26, 2024

And yes undefined means connection has not yet been checked

from hoodie-client.

gr2m avatar gr2m commented on June 26, 2024

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.

gr2m avatar gr2m commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.