subscript(dynamicMember:)
Returns the resulting value of a given key path.
- iOS
- deprecated
- macOS
- deprecated
- tvOS
- deprecated
- watchOS
- deprecated
@MainActor subscript<Value>(dynamicMember keyPath: KeyPath<ViewState, Value>) -> Value { get }
Returns the resulting value of a given key path.
@MainActor subscript<Value>(dynamicMember keyPath: KeyPath<ViewState, Value>) -> Value { get }
s22ComposableArchitecture9ViewStoreC13dynamicMemberqd__s7KeyPathCyxqd__G_tcluip
What are these?KWXK
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).
@dynamicMemberLookup @preconcurrency @MainActor final class ViewStore<ViewState, ViewAction>
A ViewStore
is an object that can observe state changes and send actions. They are most commonly used in views, such as SwiftUI views, UIView or UIViewController, but they can be used anywhere it makes sense to observe state or send actions.
@globalActor final actor MainActor
A singleton actor whose executor is equivalent to the main dispatch queue.
class KeyPath<Root, Value>
A key path from a specific root type to a specific resulting value type.
@MainActor var state: ViewState { get }
The current state.
@MainActor convenience init<State>(_ store: Store<State, ViewAction>, observe toViewState: @escaping (_ state: BindingViewStore<State>) -> ViewState, removeDuplicates isDuplicate: @escaping (_ lhs: ViewState, _ rhs: ViewState) -> Bool) where ViewAction : BindableAction, State == ViewAction.State
Initializes a structure that transforms a Store
into an observable ViewStore
in order to compute bindings from state.
@MainActor convenience init<State>(_ store: Store<State, ViewAction>, observe toViewState: @escaping (_ state: State) -> ViewState, removeDuplicates isDuplicate: @escaping (_ lhs: ViewState, _ rhs: ViewState) -> Bool)
Initializes a view store from a store which observes changes to state.
@MainActor convenience init<State, Action>(_ store: Store<State, Action>, observe toViewState: @escaping (_ state: BindingViewStore<State>) -> ViewState, send fromViewAction: @escaping (_ viewAction: ViewAction) -> Action, removeDuplicates isDuplicate: @escaping (_ lhs: ViewState, _ rhs: ViewState) -> Bool) where ViewAction : BindableAction, State == ViewAction.State
Initializes a structure that transforms a Store
into an observable ViewStore
in order to compute bindings from state.
@MainActor init<State, Action>(_ store: Store<State, Action>, observe toViewState: @escaping (_ state: State) -> ViewState, send fromViewAction: @escaping (_ viewAction: ViewAction) -> Action, removeDuplicates isDuplicate: @escaping (_ lhs: ViewState, _ rhs: ViewState) -> Bool)
Initializes a view store from a store which observes changes to state.
nonisolated let objectWillChange: ObservableObjectPublisher
@MainActor var publisher: StorePublisher<ViewState> { get }
A publisher that emits when state changes.
@MainActor func binding<Value>(get: @escaping (_ state: ViewState) -> Value, send valueToAction: @escaping (_ value: Value) -> ViewAction) -> Binding<Value>
Derives a binding from the store that prevents direct writes to state and instead sends actions to the store.
@MainActor func binding<Value>(get: @escaping (_ state: ViewState) -> Value, send action: ViewAction) -> Binding<Value>
Derives a binding from the store that prevents direct writes to state and instead sends actions to the store.
@MainActor func binding(send action: ViewAction) -> Binding<ViewState>
Derives a binding from the store that prevents direct writes to state and instead sends actions to the store.
@MainActor func binding(send valueToAction: @escaping (_ state: ViewState) -> ViewAction) -> Binding<ViewState>
Derives a binding from the store that prevents direct writes to state and instead sends actions to the store.
@discardableResult @MainActor func send(_ action: ViewAction) -> StoreTask
Sends an action to the store.
@discardableResult @MainActor func send(_ action: ViewAction, animation: Animation?) -> StoreTask
Sends an action to the store with a given animation.
@MainActor func send(_ action: ViewAction, animation: Animation?, while predicate: @escaping (_ state: ViewState) -> Bool) async
Sends an action into the store and then suspends while a piece of state is true
.
@discardableResult @MainActor func send(_ action: ViewAction, transaction: Transaction) -> StoreTask
Sends an action to the store with a given transaction.
@MainActor func send(_ action: ViewAction, while predicate: @escaping (_ state: ViewState) -> Bool) async
Sends an action into the store and then suspends while a piece of state is true
.
@MainActor func yield(while predicate: @escaping (_ state: ViewState) -> Bool) async
Suspends the current task while a predicate on state is true
.