WithViewStore - mbrandonw/swift-composable-architecture GitHub Wiki
WithViewStore
A structure that transforms a store into an observable view store in order to compute views from store state.
public struct WithViewStore<State, Action, Content>: View where Content: View
Due to a bug in SwiftUI, there are times that use of this view can interfere with some core views provided by SwiftUI. The known problematic views are:
Inheritance
DynamicViewContent
, View
Initializers
init(_:removeDuplicates:content:)
Initializes a structure that transforms a store into an observable view store in order to compute views from store state.
public init(_ store: Store<State, Action>, removeDuplicates isDuplicate: @escaping (State, State) -> Bool, content: @escaping (ViewStore<State, Action>) -> Content)
Parameters
- store: - store: A store.
- isDuplicate: - isDuplicate: A function to determine when two
State
values are equal. When values are equal, repeat view computations are removed, - content: - content: A function that can generate content from a view store.
Properties
content
let content: (ViewStore<State, Action>) -> Content
prefix
var prefix: String?
viewStore
var viewStore: ViewStore<State, Action>
body
var body: some View
Methods
debug(prefix:)
@available(*, unavailable, renamed: "debug(_:)") public func debug(prefix: String) -> Self
debug(_:)
Prints debug information to the console whenever the view is computed.
public func debug(_ prefix: String = "") -> Self
Parameters
- prefix: - prefix: A string with which to prefix all debug messages.
Returns
A structure that prints debug messages for all computations.