init(_:)
Transforms a TaskResult
into a Result
.
init(_ result: TaskResult<Success>)
Parameters
- result
A task result.
Transforms a TaskResult
into a Result
.
init(_ result: TaskResult<Success>)
ss6ResultO22ComposableArchitectures8SendableRzs5Error_pRs_rlEyAByxsAE_pGAC04TaskA0OyxGcfc
What are these?1VAOR
A task result.
import Swift
import ComposableArchitecture
The Composable Architecture (TCA, for short) is a library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind. It can be used in SwiftUI, UIKit, and more, and on any Apple platform (iOS, macOS, tvOS, and watchOS).
@frozen enum Result<Success, Failure> where Failure : Error, Success : ~Copyable
A value that represents either a success or a failure, including an associated value in each case.
enum TaskResult<Success> where Success : Sendable
A value that represents either a success or a failure. This type differs from Swift’s Result
type in that it uses only one generic for the success case, leaving the failure case as an untyped Error
.
protocol Error : Sendable
A type representing an error value that can be thrown.
protocol Sendable
func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> TaskResult<NewSuccess> where NewSuccess : Sendable
Returns a new task result, mapping any success value using the given transformation.
func flatMap<NewSuccess>(_ transform: (Success) -> TaskResult<NewSuccess>) -> TaskResult<NewSuccess> where NewSuccess : Sendable
Returns a new task result, mapping any success value using the given transformation and unwrapping the produced result.
init<Failure>(_ result: Result<Success, Failure>) where Failure : Error
Transforms a Result
into a TaskResult
, erasing its Failure
to Error
.