WQNetworkActivityIndicator 0.1.2

WQNetworkActivityIndicator 0.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2018
SPMSupports SPM

Maintained by Quan Vo.




  • By
  • quanvo87 and Wilson Ding

WQNetworkActivityIndicator

Version
License
Platform
Swift

Provides an easy way to manage the Network Activity Indicator with multiple network requests.

Features

  • Prevents a network request from prematurely hiding the Network Activity Indicator if there are still other network requests in progress
  • Prevents errors in the event that show() and hide() calls become unbalanced
  • 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. To install
it, simply add the following line to your Podfile:

pod 'WQNetworkActivityIndicator'

Usage

Show the Network Activity Indicator:

WQNetworkActivityIndicator.shared.show()

Hide the Network Activity Indicator:

WQNetworkActivityIndicator.shared.hide()

Multiple network requests:

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:

WQNetworkActivityIndicator.shared.hide(force: true)

Change the timeout

The timeout defaults to 10 seconds. Set it to 0 to disable it:

WQNetworkActivityIndicator.shared.timeout = 0

Authors

Based off MXNetworkActivityIndicator.

License

WQNetworkActivityIndicator is available under the MIT license. See the LICENSE file for more info.