File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Sources/ComposableArchitecture/SwiftUI Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,26 @@ where Content: View {
105105 }
106106}
107107
108+ extension CaseLet where GlobalAction == LocalAction {
109+ /// Initializes a ``CaseLet`` view that computes content depending on if a store of enum state
110+ /// matches a particular case.
111+ ///
112+ /// - Parameters:
113+ /// - toLocalState: A case path that can extract a case of switch store state.
114+ /// - content: A function that is given a store of the given case's state and returns a view
115+ /// that is visible only when the switch store's state matches.
116+ public init (
117+ state toLocalState: @escaping ( GlobalState ) -> LocalState ? ,
118+ @ViewBuilder then content: @escaping ( Store < LocalState , LocalAction > ) -> Content
119+ ) {
120+ self . init (
121+ state: toLocalState,
122+ action: { $0 } ,
123+ then: content
124+ )
125+ }
126+ }
127+
108128/// A view that covers any cases that aren't addressed in a ``SwitchStore``.
109129///
110130/// If you wish to use ``SwitchStore`` in a non-exhaustive manner (i.e. you do not want to provide
You can’t perform that action at this time.
0 commit comments