https://github.com/quanvo87/wqnetworkactivityindicator
Manage the Network Activity Indicator with multiple network requests.
https://github.com/quanvo87/wqnetworkactivityindicator
activity indicator network
Last synced: about 1 year ago
JSON representation
Manage the Network Activity Indicator with multiple network requests.
- Host: GitHub
- URL: https://github.com/quanvo87/wqnetworkactivityindicator
- Owner: quanvo87
- License: mit
- Created: 2018-02-04T02:42:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-04T23:31:34.000Z (over 8 years ago)
- Last Synced: 2025-02-28T20:47:21.843Z (over 1 year ago)
- Topics: activity, indicator, network
- Language: Swift
- Homepage:
- Size: 2.86 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WQNetworkActivityIndicator
[](http://cocoapods.org/pods/WQNetworkActivityIndicator)
[](http://cocoapods.org/pods/WQNetworkActivityIndicator)
[](http://cocoapods.org/pods/WQNetworkActivityIndicator)
[](https://swift.org)
Provides an easy way to manage the Network Activity Indicator with multiple network requests.
## Features
- [x] Prevents a network request from prematurely hiding the Network Activity Indicator if there are still other network requests in progress
- [x] Prevents errors in the event that `show()` and `hide()` calls become unbalanced
- [x] Has an optional timeout built into `show()`, in case a network request takes too long, or the calls become unbalanced
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Installation
WQNetworkActivityIndicator is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'WQNetworkActivityIndicator'
```
## Usage
#### Show the Network Activity Indicator:
```swift
WQNetworkActivityIndicator.shared.show()
```
#### Hide the Network Activity Indicator:
```swift
WQNetworkActivityIndicator.shared.hide()
```
#### Multiple network requests:
```swift
WQNetworkActivityIndicator.shared.show()
networkRequestA() {
WQNetworkActivityIndicator.shared.hide()
}
WQNetworkActivityIndicator.shared.show()
networkRequestB() {
WQNetworkActivityIndicator.shared.hide()
}
```
> The Network Activity Indicator will stop showing only when both requests are done.
#### Force the Network Activity Indicator to hide:
```swift
WQNetworkActivityIndicator.shared.hide(force: true)
```
#### Change the timeout
The `timeout` defaults to `10` seconds. Set it to `0` to disable it:
```swift
WQNetworkActivityIndicator.shared.timeout = 0
```
## Authors
- [Quan Vo](https://github.com/quanvo87)
- [Wilson Ding](https://github.com/dingwilson)
Based off [MXNetworkActivityIndicator](https://github.com/g20ready/MXNetworkActivityIndicator).
## License
WQNetworkActivityIndicator is available under the MIT license. See the LICENSE file for more info.