Swiftpack.co - Package - bignerdranch/Deferred

Deferred

Deferred lets you work with values that haven't been determined yet, like an array that's coming later (one day!) from a web service call. It was originally inspired by OCaml's Deferred library.

Deferred is a "futures library", probably like ones you've already heard about. Where Deferred aims to be different is by providing a small, efficient API that's easily adopted in our many consulting projects.

| Vital Statistics | |:-------------------------------------------------------------------------------------------------------| |Requires Swift 5.1 or greater | |Under MIT License | |Multiplatform | |Circle CI | |CocoaPods | |Swift Package Manager |

Don't Panic!

See Deferred's comprehensive programming guide and documentation at the Deferred Reference.

If you have a question not answered by the guide or the module comments, please open an issue!

Need Some Help?

Deferred, as an open source project, is free to use and always will be. Big Nerd Ranch offers help for Deferred, Code Audits, and general mobile app design/development services. Email us at sales@bignerdranch.com to get in touch with us for more details.

Github

link
Stars: 394

Dependencies

Used By

Total: 1

Releases

v4.1.0: Weird Amorphous Blob of Chicken - 2019-09-16 22:18:25

Deferred 4.1 improves compatibility with Apple's 2019 tools and releases.

This release is compatible with Swift 4.2, 5.0, and 5.1 on Apple platforms and Linux.

  • Bumps Swift version to 4.1, removing remaining use of unofficial Swift annotations for binary resilience.
  • Improves compatibility with Swift Package Manager in Xcode 11.

v4.0: Fire-Hose Drinking - 2019-04-11 00:29:08

Deferred 4.0 is easier-to-use and faster than ever before.

This release is compatible with Swift 4.1, 4.2, and 5.0 on Apple platforms and Linux. This will be the last release to support Swift 4.1.

As always, the latest documentation is available here.

  • Deferred optimizes for and requires Swift 4.1 or better, including Swift 5.0.
  • Deferred<Value> uses up to 70% lower memory and is up to 80% faster. (#229)
  • Task<Success> and its related types have been redesigned to address common pain points.
    • Task.Result aligns with the suite of methods and naming from SE-0235, the Swift 5 Result type.
    • The functionality of Task<Success> (map(upon:transform:), andThen(upon:start:), and so on) are conditionally available on Future and Deferred.
    • Automatic progress calculation for Task<Success> on macOS, iOS, tvOS, and watchOS have been revamped. This is ideal for, and now works better with, URLSessionTask.
    • The bare Task() is renamed Task.never.
    • Task(upon:flags:onCancel:execute:) is renamed Task.async(upon:flags:onCancel:execute:).
    • Task.repeat(upon:count:continuingIf:to:) can be used to simply re-attempt work if it fails.
    • Collection.allSucceeded() returns a combined array of all successes as its success value.
  • Future<Value> benefits from changes to Task<Success> and Deferred<Value>.
    • Implementing a custom Future requires fewer method implementations.
    • Future() is renamed Future.never.
    • Future.async(upon:flags:execute:) can be used to capture the result of asynchronous work.
    • Future and Deferred conditionally have init(success:) and init(failure:), instead of requiring init(value: .success(...)).
  • Protected<Value> and TaskResult<Value> gain additional optimizations when Deferred is imported as a module.
  • Improvements to debugging, reflection, and playground support.

v4.0 Candidate 1: An Inexplicable Confidence - 2019-02-26 05:03:46

Since 4.0 beta 4:

  • Fix all warnings under Swift 5.0
  • Address interactions with Swift 5.0 exclusivity checking

v4.0 Beta 4: A Flock of Beards - 2019-01-16 16:02:45

Since 4.0 beta 3:

  • Upgrading from Deferred 3 is substantially easier, with compiler fix-its to guide any syntax changes. Issues you may have seen around Task<Success>.Result and PreferredExecutor should no longer require any changes. (#272, #273, #276)
  • Aligns Task<Success> and Task<Success>.Result with the conventions of Result in Swift 5 (SE-0235). For example, the more verbose SuccessValue, FailureValue, and extract() are more succinct as Success, Failure, and get(). (#274)

v4.0 Beta 3: Chekhov’s Developer - 2018-11-16 08:46:15

Since 4.0 beta 2:

  • The percent calculations for Task on macOS, iOS, watchOS, and tvOS have been revamped. Explicitly creating Progress during map or returning Progress from andThen will count more than ones synthesized automatically. This ideal for, and now works better with, URLSessionTask. (#230, #259, #260, #265, #267, #269).
  • Various minor cleanups to the generation of docs. (Available here.)
  • Sets the Swift version in CocoaPods to inhibit Swift 4.2 warnings. (#261, #262)
  • Rewritten and expanded documentation for Task. (#266)

v4.0 Beta 2: Hyperphantastic - 2018-09-27 00:50:42

Since v4.0 beta 1:

  • Fixes an "ambiguous method" error introduced in #254. (#257)

v4.0 Beta 1: Architecture Rap Battle - 2018-09-20 16:49:40

Deferred 4.0 brings the latest and greatest of Swift to Deferred, and is optimized to be faster and easier-to-use than ever before.

  • Deferred supports and requires Swift 4.1 or better. (#200, #201, #222, #237, #250, #251)
  • Deferred<Value> uses up to 70% lower memory and is up to 80% faster. (#229)
  • Task<SuccessValue> and its related types have been redesigned to address common pain points. (#243)
    • Collection.allSucceeded() returns a combined array of all successes as its success value. (#217)
    • TaskResult<Value> provides common-case map(_:) and flatMap(_:) methods. (#244)
    • Task.fallback(upon:to:) can throw from within its handler. (#245, #255)
    • Task() is renamed Task.never. (#247)
    • Task(upon:flags:onCancel:execute:) is renamed Task.async(upon:flags:onCancel:execute:). (#248)
    • The functionality of Task<SuccessValue> (map(upon:transform:), andThen(upon:start:), recover(upon:substituting:) fallback(upon:to:), and so on) are conditionally available on Future and Deferred. (#253)
    • Task<SuccessValue> convenience initializers are more aligned with the Swift API Design Guidelines. (#254)
    • Task.repeat(upon:count:continuingIf:to:) can be used to simply re-attempt work if it fails. (#255)
  • Future<Value> and its related types benefits from changes to Task<SuccessValue> and Deferred<Value>.
    • Implementing a custom Future requires fewer method implementations. (#215, #216)
    • Future() is renamed Future.never. (#247)
    • Future.async(upon:flags:execute:) can be used to capture the result of asynchronous work. (#248)
    • Future and Deferred conditionally have init(success:) and init(failure:), instead of requiring init(value: .success(...)). (#254)
  • Improvements to debugging, reflection, and playgrounds. (#202, #212, #214, #223)
  • Protected<Value> and TaskResult<Value> are annotated for binary resilience in Swift. Their use across module boundaries should be much faster. (#226, #243)

v3.3.2: World Wide Developer Contention - 2018-06-19 17:00:16

  • Improves compatibility with Xcode 10's new build system (#237, #238)

v3.3.1: The Pod Keeps Rolling On - 2018-05-12 07:33:40

  • Fixes warnings under Swift 4.1 about CustomPlaygroundQuickLookable (#231)
  • Compatibility with CocoaPods 1.5.0 static library support (#218, #232)
  • Fixes an issue with URLSessionTask and implicit progress in Task.andThen (#230, #234)

v3.3.0: It Just Happened That Way - 2018-02-08 17:04:34

  • Convenience initializer to create Task from future that cannot fail (#195)
  • Quiets project warnings under Xcode 9.3 (#197)

Due to a cosmic accident, this release also supports Swift 3 syntax. The next planned release shall not.

This release will be submitted to the Swift Source Compatibility Suite for Swift 3.x compatibility.

v3.2.0: Last One Out, Quit Xcode - 2017-09-21 17:37:58

A compatibility release to fix any syntax warnings under Swift 3.2.

v3.1.2: Exclusively Accessed - 2017-07-24 18:13:50

  • Quiet errant exclusive access errors in Swift 3.2 (#189, SR-5439)
  • Address a race condition while cancelling chains of tasks (#190, thanks @piercifani!)

v3.1.1: All's Fair in Love and TSAN - 2017-06-19 21:57:30

  • Fix all warnings under Swift 3.2 (#186)
  • Avoid TSAN false positives under Swift 3.2 from using Swift inout to convert to C pointers (#187)

v3.1: Doing the Shuffle - 2017-05-11 05:47:11

  • Moves TaskResult<T> to Task<T>.Result for Swift 3.1. This is a source-compatible change; the old names have been deprecated and will be removed in a future release. (#176)
  • Fix test targets causing a dependency on XCTest when using Swift Package Manager. (#177-ish, #180)

v3.0: Queues, I Love You but You're Bringing Me Down - 2017-03-28 21:35:39

3.0 is a comprehensive, breaking release of Deferred, providing support for Swift 3.x and adopting the API Design Guidelines.

Since 2.0:

  • Available on non-Apple platforms.
  • Integrates with Swift 3's modernized syntax for Grand Central Dispatch.
  • Improved performance.
  • Enhanced debugging and Playgrounds support.

Deferred 3 is our best release yet. Thanks to all of our contributors, including @piercifani, @jgallagher, and @jeremy-w. We can't wait to see what you build with it.

v3.0 Candidate 2: Tricksy Bits - 2017-03-28 21:33:12

Since 3.0.0-rc.1:

  • Add Task.fallback(upon:to:). (#149)
  • Fixes to Playground support. (#161)
  • Progress-tracking bug fix in Task.recover(upon:substituting:). (#162)

v3.0 Candidate 1: The Walking Thread - 2017-03-28 21:33:05

Since 3.0.0-beta.3:

  • Work around a bug in the Swift Standard Library around SE-0116. (#150, thanks @preble!)
  • Fix deployment issues on Jenkins and other CI (#152, thanks @lyricsboy!)
  • Move to Fastlane and swiftenv to automate the project.

v3.0 Beta 3: Key-Value Obfuscation - 2016-11-01 02:38:37

  • Task: Fixes for mysterious threading violations (#144, and thanks to the ever-vigilant @piercifani)

v2.2.1: Deferred Del Vesuvio - 2016-10-31 18:33:53

Threading fixes from the newly-introduced Task code.

v3.0 Beta 2: A Little Bit of Every - 2017-03-28 21:32:55

  • Compatibility with Xcode 8.1 and Swift 3.0.1.
  • Fix bugs work, around several compiler bugs (#129, #130, #132, #137, #138, with gracious thanks to @piercifani)
  • Introduce a Future.every(per:), a low-cost alternative to Future.map(upon:transform:).
  • Revamp Locking types
  • Improve sidebar appearance of Futures and Protecteds in iPad Playgrounds
  • Clean up and revamp documentation

v3.0 Beta 1: A Swift Kick - 2016-09-28 15:15:58

3.0 is a majorly breaking release, providing support for Swift 3.0 and adopting the API Design Guidelines.

  • Makes extensive use of the modernized API for Grand Central Dispatch.
  • All API names updated to provide a more fluent interface. (#21, #66, #101, #119)
  • Fully supports building and testing using Swift Package Manager. (#125)
  • Runs on Linux. (#54, #125)

v2.2: Task Del Giorno - 2016-09-24 11:30:36

  • Introduces the Task<SuccessValue> class, a composition of a Future<Result> and NSProgress. (#98, #111)
  • Introduces sugar for upon(_:) with Result successes and failures (#98)
  • Introduces sugar for fill(_:) with Result successes and failures (#98)
  • Fix API unintentionally exposed to ObjC in 2.0.0 (#111)

v2.2 Candidate: Task de Napoli - 2016-09-11 06:46:52

  • Introduces the Task<SuccessValue> class, a composition of a Future<Result> and NSProgress. (#98, #111)
  • Introduces sugar for upon(_:) with Result successes and failures (#98)
  • Introduces sugar for fill(_:) with Result successes and failures (#98)
  • Fix API unintentionally exposed to ObjC in 2.0.0 (#111)

v2.0: No Promises - 2016-07-07 05:06:41

Deferred is a milestone release of our framework for Swift 2.x, used daily by your friends at Big Nerd Ranch.

Since 1.0:

  • An extensible protocol-oriented concept of Futures and Promises, which compose into the Deferred you know and love.
  • Deferred itself is much more efficient, requiring no locking overhead.
  • Introduce ExecutorType as an alternative to directly using Dispatch queues.
  • ReadWriteLock and LockProtected support throws.
  • Completely rewritten documentation.
  • Enhanced debugging and Playgrounds support.
  • Support for macOS, tvOS, and watchOS.

Special thanks to @cbkeur, @jeremy-w, @jgallagher, @lyricsboy, and @randomstep for their hours of rubber-ducking and passion for the specific color of this bikeshed.

v2.0 Release Candidate: Deferred County Superior Court - 2016-04-14 04:57:02

Since 2.0b6:

  • Improvements to documentation (#78, #89, #94, #96)
  • Better support for playgrounds and debugging on futures and LockProtected (#80, #85)
  • Support for Swift 2.2 (#81)
  • Add a convenience initializer to Future<Value> that never fills. This is great for stub APIs, and could previously be accomplished with Future(Deferred()). (#82)
  • Expose the generic GCD queue used by the no-argument upon as public API (#83)
  • Introduce ExecutorType as an alternative to directly using GCD queues (#89)
  • Replace IgnoringFuture.init(_:) with FutureType.ignored(). The IgnoringFuture type may be removed in a future release. (#92)

v2.0 Beta 6: Singing In The Rain - 2016-04-12 13:29:52

  • Memory leak fix (#76, thanks @cbkeur!)

v2.0 Beta 5: It'll Get There Eventually! - 2016-02-18 02:49:59

  • Fixes bug in Deferred.wait(_:). (#67; thanks @preble!)
  • Performance improvements for locking types (#69)
  • Support for Swift Package Manager (#69)
  • Basic compatibility with Linux (assuming availability of Grand Central Dispatch; #69)
  • Makes map(upon:transform:) and flatMap(upon:transform:) correctly return Future (#71; #72)

v2.0 Beta 4: Do? There Is No Do. There Is Only Try. - 2015-12-19 17:02:32

  • Cleanups and refactorings to more clearly define the use of GCD. (Part #54)
  • ReadWriteLock and LockProtected are all now rethrows-compatible. (#55)
  • Adds 3- and 4-argument versions of and. (#52)
  • Turn .ignoringValue into a full IgnoringFuture type. (#60)
  • Renames AnyFuture to simply Future. (#60)
  • Adds tvOS and watchOS targets. (#62)
  • Adds CocoaPods support. (#62)

v2.0 Beta 3: General Atomics International - 2015-11-30 18:22:59

Requires Swift 2.1 (Xcode 7.1 and 7.2)

  • Significant internal reworking. (#30)
    • Deferred now requires Swift 2.1, and deploys to OS X 10.10 and iOS 8.0.
    • Removes any dependency on Foundation in Deferred itself.
    • Deferred.fill(_:) and Deferred.upon(_:) are each much more efficient, and involve no threading overhead.
    • Removes Deferred.value. Use the new Deferred.wait(_:) method instead.
    • Adopts GCD QoS classes for improved performance.
    • Improves unit test coverage.
  • any(_:) and all(_:) now take any collection. (#30)
  • Restructures convenience methods into protocol extensions. (#33)
    • Introduces AnyFuture for erasing the type of an underlying Deferred or Task. (#24)
  • Revamps any to flatten nested Deferred instances. (#42)
  • Improve coverage and automatically publish documentation. (#53)

v2.0 Beta 2: Once Upon a Queue - 2015-09-01 02:59:02

Adds uponMainQueue function for convenient resolution of the value on the main queue.