GroupWork is an easy to use Swift framework that helps you orchestrate your concurrent, asynchronous functions in a clean and organized way

Overview

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.

You might also like...
Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch

Async Now more than syntactic sugar for asynchronous dispatches in Grand Central Dispatch (GCD) in Swift Async sugar looks like this: Async.userInitia

⏳ Collection of Swift 5.5 async/await utility functions.

⏳ FunAsync Collection of Swift 5.5 async/await utility functions. Throw - Result conversion asyncThrowsToAsyncResult asyncResultToAsyncThrows More C

🍴 Parallelize two or more async functions

Fork Parallelize two or more async functions What is Fork? Fork allows for a single input to create two separate async functions that return potential

Pomodoro is a macOS status bar application written in SwiftUI, which allows you to control your work and break time, exploiting the pomodoro-technique.
Pomodoro is a macOS status bar application written in SwiftUI, which allows you to control your work and break time, exploiting the pomodoro-technique.

Pomodoro Pomodoro is a macOS status bar application which allows you to control your work and break time. Through this application you will be able to

New Way Of Working Around With Closures.

Closured New Way Of Working Around With Closures. Are you tired of old-school callback closures? Are you always mess up with capturing references on a

A Swift microframework for very easy atomic values.

Atomic Atomic is a fast, safe class for making values thread-safe in Swift. It is backed by pthread_mutex_lock which is the fastest, most-efficient lo

A simple network layer for use in small iOS projects with async/await support

SimpleNetwork Intro SimpleNetwork is simple network layer for use in small projects. Swift Package Manager Note: Instructions below are for using Swif

Example project showing how to use async/await with iOS 13
Example project showing how to use async/await with iOS 13

ios13AsyncAwait Example project showing how to use async/await with iOS 13 Article This source code is a part of an article published at This Dev Brai

SwiftyTimer allows you to instantly schedule delays and repeating timers using convenient closure syntax. It's time to get rid of Objective-C cruft.

SwiftyTimer Modern Swifty API for NSTimer SwiftyTimer allows you to instantly schedule delays and repeating timers using convenient closure syntax. It

Comments
  • enable spm

    enable spm

    i changed the file structure to make it easy to enable SPM. this also resulted in:

    • updated Podspec, not sure if correct
    • travis originally failed, so I made the changes you see. They seem to run the test and pass...do you know the diff between what you did and what I put?
    opened by quanvo87 4
  • 0.0.1

    0.0.1

    • Added podspec for CocoaPod support
    • Set Deployment Target to 8.0

    Once these changes have been merged, and release 0.0.1 has been tagged in the repo, either you or I should be able to push the podspec up to CocoaPods. You can find the instructions on getting started with pod trunk here.

    I have also added a list of suggestions you might want to consider adding/doing before and after release. Not sure how much of this we want to do vs leave for later releases vs don't do at all. We can discuss and do anything you think would be a good idea on this PR before merging.

    Things to Consider Before Release:

    • Branding
      • Creating longer description optimized w/ keywords for search. (We already have the short summary, but need a longer description for README introduction and podspec).
      • Maybe some sort of small logo/header image for README? Maybe just a stylized "GroupWork" image. Images > Text.
    • README
      • Badges for a "quick glance" for Swift 4 support, latest pod version, travis build status (if we decide to test), etc.
      • Fix Link to Docs
      • Add instructions to install via CocoaPods/Carthage/Manual
    • Implementing some of GitHub's special md files
      • Changelog
      • Issue/PR Templates
      • etc..
    • Generate Jazzy Docs
    • Maybe an example project using GroupWork

    Things to Consider After Release:

    • Add to awesome-ios and awesome-swift
    • Generate hits by posting about it (Twitter, FB, HN, Reddit, etc.)
    • Hit #1 on trending and 🎉
    opened by dingwilson 2
  • do

    do

    Things to Consider Before Release:

    • Branding
      • [x] Creating longer description optimized w/ keywords for search. (We already have the short summary, but need a longer description for README introduction and podspec).
      • [x] Maybe some sort of small logo/header image for README? Maybe just a stylized "GroupWork" image. Images > Text.
    • README
      • [x] Badges for a "quick glance" for Swift 4 support, latest pod version, travis build status (if we decide to test), etc.
      • [x] Fix Link to Docs
      • [x] Add instructions to install via CocoaPods/Carthage/Manual
    • Implementing some of GitHub's special md files
      • [ ] Changelog
      • [ ] Issue/PR Templates
      • etc..
    • [x] Generate Jazzy Docs
    • [x] Maybe an example project using GroupWork

    Things to Consider After Release:

    • [ ] awesome-ios
    • [ ] awesome-swift
    • [ ] Generate hits by posting about it (Twitter, FB, HN, Reddit, etc.)
    • [ ] Hit #1 on trending and 🎉
    opened by quanvo87 1
Releases(0.0.6)
Owner
Quan Vo
iOS Engineer
Quan Vo
Egg Timer app helps you to cook your egg in the way you want

Egg Timer Egg Timer app helps you to cook your egg in the way you want. You need to decide on how do you want to eat your egg than just click the egg

Emrullah Cirit 2 Nov 29, 2022
Async and concurrent versions of Swift’s forEach, map, flatMap, and compactMap APIs.

CollectionConcurrencyKit Welcome to CollectionConcurrencyKit, a lightweight Swift package that adds asynchronous and concurrent versions of the standa

John Sundell 684 Jan 9, 2023
AsyncTimer is a precision asynchronous timer. You can also use it as a countdown timer

AsyncTimer ?? Features Can work as a countdown timer Can work as a periodic Timer Can work as a scheduled timer Working with user events (like: scroll

Adrian Bobrowski 26 Jan 1, 2023
Job Scheduler for IOS with Concurrent run, failure/retry, persistence, repeat, delay and more

SwiftQueue Schedule tasks with constraints made easy. SwiftQueue is a job scheduler for iOS inspired by popular android libraries like android-priorit

Lucas Nelaupe 367 Dec 24, 2022
A general purpose embedded hierarchical lock manager used to build highly concurrent applications of all types. Same type of locker used in many of the large and small DBMSs in existence today.

StickyLocking StickyLocking is a general purpose embedded lock manager which allows for locking any resource hierarchy. Installable Lock modes allow f

Sticky Tools 2 Jun 15, 2021
AwaitKit is a powerful Swift library which provides a powerful way to write asynchronous code in a sequential manner.

AwaitKit is a powerful Swift library inspired by the Async/Await specification in ES8 (ECMAScript 2017) which provides a powerful way to write asynchronous code in a sequential manner.

Yannick Loriot 752 Dec 5, 2022
Futures is a cross-platform framework for simplifying asynchronous programming, written in Swift.

Futures Futures is a cross-platform framework for simplifying asynchronous programming, written in Swift. It's lightweight, fast, and easy to understa

David Ask 60 Aug 11, 2022
A demonstration for bridging between Combine and your new async functions

CombineAsyncually This is a DEMONSTRATION of how you can bridge the new async / await functionality in Swift 5.5 with Combine. There is NO WARRANTY. T

null 48 Dec 4, 2022
Make your logic flow and data flow clean and human readable

Flow What's Flow Flow is an utility/ design pattern that help developers to write simple and readable code. There are two main concerns: Flow of opera

null 18 Jun 17, 2022
Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch (iOS7+ and OS X 10.9+ compatible)

Async.legacy Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch (GCD) Async rewritten for iOS7 and OS X 10.9 Compatibility

Joseph Lord 31 Jul 1, 2019