🏷️ In android projects it is common to communicate with a network and get data from a remote server or post data into remote server.
🏷️ There is a common case to check connectivity before performing either of the case.
🏷️ Sometims when the connectivity fails and gets connected, again we need to show a notification just like how youtube does.
🏷️ Everytime we used to call a API, we check connectivity and say if we have multiple API's, we do the same check multiple times.
🏷️ And to monitor the connectivity change we used to listen to broadcast from the android system
🏷️ With the introduction of live data and the life-cycle observers, we can have a better implementation to monitor and react to the network changes.
🏷️ We can store the changes in a variable and just use that to determine the state of the network instead of checking network everytime.
🏷️ By this way is efficient and less error prone and the is single source of truth for current connectivity state.
If you feel like support me a coffee for my efforts, I would greatly appreciate it.
Read contribution guidelines for more information regarding contribution.
Feature requests are always welcome, File an issue here.
Support it by clicking the ⭐ button on the upper right of this page. ✌️
This project is licensed under the Apache License 2.0 - see the LICENSE file for details