Hacker News new | comments | show | ask | jobs | submit login

Yeah, I saw a lib the other day that tried to offer this but was pretty hit and miss, and checking into the methods available didn't fill me with confidence. Right now I'm only considering the client offline if an attempt to hit the server fails. If they're trying to save something, queue it up to do later, if they're trying to retrieve something, check if theres a copy locally, if not let them know what's going on.

The problem with this method is ideally you'd like the client to know it's reconnected as soon as possible, and start working through the queue. I figured the most foolproof way was just periodically trying to talk to the server when you think you're offline. It'd probably be better if you had a solid method of receiving actual network related events like disconnecting and reconnecting, but the lazy 'just keep checking' method is workable.

The bonus of it is it works the same if it's a problem on the servers end.

This is the right approach; there are all kinds of reasons a server API might fail and being offline is only one of them.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact