Reachability.swift
Reachability.swift copied to clipboard
Allow startNotifier to optionally skip the initial check.
Because sometimes you only want to know when network comes back. Furthermore, the initial check is not on main thread which can cause some issues for clients.
Certainly we needed this change to get rid of nasty crashes and difficult thread timing behaviour in our app. In our use case we only cared to know when connectivity was re-established for auto-reload functionality. So we didn't want to initial check, and occasionally the initial callback would arrive before the result of startNotifier had actually been assigned, so we didn't have access to the Reachability object (which we wanted to check if we had WiFi or mobile access). Which caused crashes until we figured out what was going on.
@ashleymills any update on this? seems like a very cool feature to have. I think checkImmediately
is set to true
by default to leave the current behavior unchanged. Am I wrong?
I can open a new PR if you don't have time to look.
I'll take another look at this one
Any update on this? I also don't want to be notified initially, only to be notified when there is a change in reachability. If you are not merging this one, can you advice me for a workaround?
This PR has been outstanding for several years and I just had to fork the repo to accomplish the very same thing. It would be good to merge this and get it done.