ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - quanvo87/GroupWork: Easy, concurrent, asynchronous tasks in Swift.
Easy, concurrent, asynchronous tasks in Swift. Contribute to quanvo87/GroupWork development by creating an account on GitHub.
Visit Site

GitHub - quanvo87/GroupWork: Easy, concurrent, asynchronous tasks in Swift.

GitHub - quanvo87/GroupWork: Easy, concurrent, asynchronous tasks in Swift.

iOS Linux Swift CocoaPods Version Status CocoaPods CocoaPods Carthage compatible Build Status MIT License

GroupWork is an easy to use Swift framework that helps you orchestrate your concurrent, asynchronous functions in a clean and organized way. This helps make large functions with multiple asynchronous tasks more clear and easy to follow.

Contents

  1. Requirements
  2. Installation
  3. Documentation
  4. Example Usage
  5. Working Example
  6. License
  7. Authors

Requirements

Swift 4

Installation

CocoaPods

For CocoaPods, add to Podfile:

pod 'GroupWork', '~> 0.0'

Carthage

For Carthage, add to Cartfile:

github "quanvo87/GroupWork"

Swift Package Manager

For SPM, add to your package dependencies:

.package(url: "https://github.com/quanvo87/GroupWork.git", .upToNextMinor(from: "0.0.0"))

Manually

  • for projects, drag GroupWork.swift to the project tree
  • for workspaces, include the whole GroupWork.xcodeproj

Documentation

Here

Example Usage

End Goal

import GroupWork

...

func complexFunc(completion: @escaping (Bool) -> Void) {
  let work = GroupWork()

  work.asyncFuncA()
  work.asyncFuncB()
  work.asyncFuncC()

  work.allDone() {
    completion(work.result)
  }
}

...

complexFunc is a function that returns the result of three asynchronous functions asyncFuncA(), asyncFuncB(), and asyncFuncC(), running concurrently. The completion handler is called only when all these functions have completed. Usage of this library has enabled the above clean interface. This can be scaled to much higher than three asynchronous functions.

notes:

  • the asynchronous functions should be able to run concurrently without affecting each other
  • work.result is only a simple Bool
  • this is not an answer to callback hell

Set Up

There is some set up required in order to create complexFunc() from above:

import GroupWork

extension GroupWork {
  func asyncFuncA() {
    start()
    networkCallA() { (result) in
      self.finish(withResult: result)
    }
  }

  func asyncFuncB() {
    start()
    networkCallB() { (result) in
      self.finish(withResult: result)
    }
  }

  func asyncFuncC() {
    start()
    networkCallC() { (result) in
      self.finish(withResult: result)
    }
  }
}

Now you can create a GroupWork, and call work.simpleFuncA() on it like in the example.

notes:

  • start() must be called before an asynchronous task
  • finish() must be called in the completion handler of an asynchronous task
  • start() and finish() calls must be balanced

Working Example

The tests have a working example.

License

MIT LICENSE

Authors

Please provide attribution, it is greatly appreciated.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory