Skip to content

4.0.0 Beta 4

Pre-release
Pre-release
Compare
Choose a tag to compare
@danthorpe danthorpe released this 30 Oct 14:31
· 386 commits to development since this release

4.0.0 Beta 4

Beta 4 is a significant maturation over Beta 3. There are a couple of breaking changes here which I will call out explicitly. Overall however, the APIs have been refined, adjusted and extended, bugs have been fixed, and tests have been stabilised.

Additionally, Beta 4 now supports integration via Carthage and CocoaPods including full support for TestingProcedureKit and CocoaPod subspecs.

Breaking API Changes

  1. #519 Renames

    • AuthorizationStatusProtocol to AuthorizationStatus.
      Thanks to @martnst.
  2. #520 Renames:

    • GetAuthorizationStatus to GetAuthorizationStatusProcedure,
    • Authorize to AuthorizeCapabilityProcedure
      Thanks to @martnst again.
  3. #527, #528, #541, #546 ResultInjection

    ResultInjection, which is what we call the methodology of automatically injecting the result from one procedure as the requirement of a dependency, has been revamped in Beta 4.

    • It is now an extension on ProcedureProctocol.

    • The API now support injection via a transform block. For example, lets assume that we are using NetworkDataProcedure which requires a URLRequest, and we have a procedure which results in a URL, we might do this:

      download.injectResult(from: getURL) { url in
          return URLRequest(url: $0) 
      }
    • Refactors ResultInjection protocol to use PendingValue<T>. Now the requirement and result properties are PendingValue<Requrement> and PendingValue<Result> respectively. This avoids the need to use explicitly unwrapped optionals for the Requirement. For example:

      class MyProcedure: Procedure, ResultInjection {
          var requirement: PendingValue<Foo> = .pending
          var result: PendingValue<Bar> = .pending
      }
    • Extension APIs automatically unwrap optionals. This means that where a Result? == Requirement the result will be automatically unwrapped.

New Features

  1. #516, #534: AnyProcedure

    This is a new procedure which supports composition of any Procedure subclass conforming to ResultInjection APIs with complete type erasure. This makes the following usage possible:

    • Inject / store generic Procedure subclasses into other types.
    • Store many different types of Procedure subclasses in a homogenous storage container, so long as they have the same sub-type Requirement and Result.

    An example of where this is useful would be with a strategy design pattern, where each strategies likely has a different Procedure subclass, but the Requirement (i.e. input) and Result (i.e. output) of each is the same. Given this, any strategy can be injected into a GroupProcedure or other structure type-erased using AnyProcedure<Requirement,Result>.

  2. #523 ProcedureKitCloud

    Added a ProcedureKitCloud framework, which currently just
    includes Capability.CloudKit. Unfortunately the full CloudKitProcedure class did not get finished in time for this beta. However, it is very close to being finished, see PR: #542.

  3. #524, #525, #526, #538,#547 ProcedureKitNetwork

    ProcedureKitNetwork is a framework which offers a very simple wrapper around URLSession completion based APIs. Currently only for NetworkDataProcedure which uses the URLSessionDataTask based APIs. If you need to use the delegate based APIs you cannot use this Procedure subclass.

    Additionally, there is full support in TestingProcedureKit for using TestableURLSession which allows framework consumers to check that the session receives the correct request etc.

  4. #536 .then { } API

    Added an alternative way of adding dependencies on Operation in a chain. For example:

    let operations = foo.then(do: bar).then { Baz() }

    Thanks to @jshier for initial idea and suggestion - sorry it took so long to get done!

  5. #508, #553 CocoaPods

    Note here that the standard pod is just the core framework. This is Extension API compatible with support for all 4 platforms. To get iOS related classes, such as BackgroundObserver which are not Extension API compatible use ProcedureKit/Mobile, likewise for ProcedureKit/Location, ProcedureKit/Network, ProcedureKit/Cloud etc.
    TestingProcedureKit, has its own podspec.

  6. #537 ResilientNetworkProcedure Beta

    This is a RetryProcedure subclass which is designed to add network resiliency around network request based Procedure subclasses. This procedure works by providing a value which corresponds to ResilientNetworkBehavior protocol, and a closure which returns a new network request procedure. The protocol allows the framework consumer to decide how to interpret status/error codes, and trigger retries.

  7. #550 ConcurrencyTestCase

    This is a new ProcedureKitTestCase subclass in TestingProcedureKit which has methods to help test concurrency issues in ProcedureKit itself, but also in your applications. Thanks to @swiftlyfalling for adding it.

  8. #552 wait(forAll: [Procedure]) API

    This is added to ProcedureKitTestCase. Thanks to @swiftlyfalling for adding this.

  9. #554 Adds did(execute: Procedure) observer callback.

    Use this with great caution, as it may not always do what you expect depending on the behavior of the execute method of the procedure. From the discussion:

    all that's currently guaranteed is that didExecuteObservers will be called after execute() returns. The rest is up to the specifics of the Procedure subclass implementation.
    This will likely be improved before 4.0.0 is final.

Bug Fixes etc

  1. #518 Fixes failing release build regression.
  2. #531 Adds default empty implementation to some of the Queue Delegate methods. Feedback welcome here!
  3. #533 Adds an area in the repo for talks and presentations which have been given about Operations or ProcedureKit. Watch out for @jshier who will be speaking at Swift Summit ProcedureKit and you on Nov 7th. πŸ˜€πŸ˜€πŸ˜€
  4. #532 Fixes a bug where GroupProcedure would collect errors from its children after it had been cancelled. This is a bit annoying, if a group is cancelled, it will cancel all of its children with an error (ProcedureKitError.parentDidCancel(error)), but it would then receive in its delegate all of those errors from the children.
  5. #539 Tweaks to cancel BlockProcedure stress tests.
  6. #540 Moves import ProcedureKit into umbrella headers.
  7. #544 Fixes BlockProcedure stress tests - thanks to @swiftlyfalling.
  8. #545 Fixes a bug where ExclusivityManager was not thread safe. Thanks to @myexec for reporting the bug, and @swiftlyfalling for fixing it.
  9. #549 Fixes random crashed in QueueTestDelegate - thanks to @swiftlyfalling for fixing this, and generally being awesome at identifying where code paths are not thread safe πŸ’š.
  10. #557 Fixes some CI errors in Fastfile.
  11. #558 #559 Fixes issue with Xcode 8.1 release builds, thanks so much to @pomozoff for figuring out the issue here!
  12. #556 Adds group concurrency tests using the new ConcurrencyTestCase. Thanks to @swiftlyfalling for their awesome contributions!