hoodiehq / hoodie-connection-status

:dog: connection status API for the browser
Apache License 2.0
5 stars 10 forks source link

Implement connectionStatus.startChecking(options) & connectionStatus.stopChecking() #13

Closed courajs closed 8 years ago

courajs commented 8 years ago

.check() can trigger a recurring check, but returns a single promise. The promise will resolve once, or reject once, even if the connection status changes later. I think you'd be doing these for different reasons. The recurring check would likely be for some user notification. A one-time check is more likely in response to something, like an error. I think maybe these two things should be separate. Like a .check() that returns a promise, and a .startChecking({interval, timeout}) to start getting the events.

gr2m commented 8 years ago

good thinking, I think having two methods for one-time checks vs intervals makes it more clear. And with .startChecking({interval, timeout}) we can also add .stopChecking(). I'd say let's do that :)

gr2m commented 8 years ago
connectionStatus.startChecking({
  interval: 30000, // ms
  timeout: 3000 // request timeout before aborting request
}) // returns undefined
connectionStatus.stopChecking() // returns undefined
jennazee commented 8 years ago

I'll give this a shot!

gr2m commented 8 years ago

done via 33d9e98