value
Returns the success value as a throwing property.
- iOS
- deprecated
- macOS
- deprecated
- tvOS
- deprecated
- watchOS
- deprecated
var value: Success { get throws }
Returns the success value as a throwing property.
var value: Success { get throws }
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).
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
.
init<Failure>(_ result: Result<Success, Failure>) where Failure : Error
Transforms a Result
into a TaskResult
, erasing its Failure
to Error
.
init(catching body: () async throws -> Success) async
Creates a new task result by evaluating an async throwing closure, capturing the returned value as a success, or any thrown error as a failure.
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.
func map<NewSuccess>(_ transform: (Success) -> NewSuccess) -> TaskResult<NewSuccess> where NewSuccess : Sendable
Returns a new task result, mapping any success value using the given transformation.