4.0.0 Beta 4
Pre-release4.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
-
#519 Renames
AuthorizationStatusProtocol
toAuthorizationStatus
.
Thanks to @martnst.
-
#520 Renames:
GetAuthorizationStatus
toGetAuthorizationStatusProcedure
,Authorize
toAuthorizeCapabilityProcedure
Thanks to @martnst again.
-
#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 aURLRequest
, and we have a procedure which results in aURL
, we might do this:download.injectResult(from: getURL) { url in return URLRequest(url: $0) }
-
Refactors
ResultInjection
protocol to usePendingValue<T>
. Now therequirement
andresult
properties arePendingValue<Requrement>
andPendingValue<Result>
respectively. This avoids the need to use explicitly unwrapped optionals for theRequirement
. 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
-
This is a new procedure which supports composition of any
Procedure
subclass conforming toResultInjection
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-typeRequirement
andResult
.
An example of where this is useful would be with a strategy design pattern, where each strategies likely has a different
Procedure
subclass, but theRequirement
(i.e. input) andResult
(i.e. output) of each is the same. Given this, any strategy can be injected into aGroupProcedure
or other structure type-erased usingAnyProcedure<Requirement,Result>
. - Inject / store generic
-
#523 ProcedureKitCloud
Added a ProcedureKitCloud framework, which currently just
includesCapability.CloudKit
. Unfortunately the fullCloudKitProcedure
class did not get finished in time for this beta. However, it is very close to being finished, see PR: #542. -
#524, #525, #526, #538,#547 ProcedureKitNetwork
ProcedureKitNetwork is a framework which offers a very simple wrapper around
URLSession
completion based APIs. Currently only forNetworkDataProcedure
which uses theURLSessionDataTask
based APIs. If you need to use the delegate based APIs you cannot use thisProcedure
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. -
#536
.then { }
APIAdded 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!
-
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 useProcedureKit/Mobile
, likewise forProcedureKit/Location
,ProcedureKit/Network
,ProcedureKit/Cloud
etc.
TestingProcedureKit, has its own podspec. -
#537
ResilientNetworkProcedure
BetaThis is a
RetryProcedure
subclass which is designed to add network resiliency around network request basedProcedure
subclasses. This procedure works by providing a value which corresponds toResilientNetworkBehavior
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. -
#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. -
#552
wait(forAll: [Procedure])
APIThis is added to
ProcedureKitTestCase
. Thanks to @swiftlyfalling for adding this. -
#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
- #518 Fixes failing release build regression.
- #531 Adds default empty implementation to some of the Queue Delegate methods. Feedback welcome here!
- #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. πππ
- #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. - #539 Tweaks to cancel
BlockProcedure
stress tests. - #540 Moves
import ProcedureKit
into umbrella headers. - #544 Fixes
BlockProcedure
stress tests - thanks to @swiftlyfalling. - #545 Fixes a bug where
ExclusivityManager
was not thread safe. Thanks to @myexec for reporting the bug, and @swiftlyfalling for fixing it. - #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 π. - #557 Fixes some CI errors in Fastfile.
- #558 #559 Fixes issue with Xcode 8.1 release builds, thanks so much to @pomozoff for figuring out the issue here!
- #556 Adds group concurrency tests using the new
ConcurrencyTestCase
. Thanks to @swiftlyfalling for their awesome contributions!