Closed courajs closed 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 :)
connectionStatus.startChecking({
interval: 30000, // ms
timeout: 3000 // request timeout before aborting request
}) // returns undefined
connectionStatus.stopChecking() // returns undefined
I'll give this a shot!
done via 33d9e98
.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.