Custom pipeline operators for easy chaining in Swift
22 ./ Utils.funcThatConvertsIntIntoString ./ { print($0) }See more examples of usage in unit tests.
| Operator | Description |
|---|---|
./ |
Pass through — transform value and continue the chain |
.? |
Pass through unwrapped — unwrap optional, then transform |
.+ |
Mutate — modify value in place via inout |
.- |
Inspect — observe value without modifying it |
.* |
End chain — transform and return final result |
.?* |
End chain unwrapped — unwrap optional, transform, and return |
.! |
Ensure condition — assert a condition or throw |
?! |
Unwrap or throw — unwrap optional or throw an error |
All operators have async and async throws variants, making them compatible with actors and structured concurrency.
Use take() as an entry point to wrap any value in a SimpleWrapper, which provides:
map— transform the wrapped value (sync + async)inspect— observe the value without changing it (sync + async)mutate— modify the value in place (sync + async)
Convenience extensions for working with Combine publishers:
waitForFirstResult()— await the first published valueobserve()— subscribe with simplified callbacksexecuteNow()— immediately execute and observeensureMainThread()— receive values on the main threadmutate()— apply mutations via publisher output
Pipeline.FailedConditionCheck— thrown when a.!condition failsPipeline.CompletedWithoutValue— thrown when a publisher completes without emitting a value
Install using SwiftPM.
.package(url: "https://github.com/XCEssentials/XCEPipeline.git", from: "4.0.0")