This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch action { | |
case .task: | |
return .observe { | |
myDependency.events => Action.onEvent | |
} | |
} | |
// where this is put at the end of the View: | |
.task { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct TestReducer: Reducer { | |
@Dependency(\.repo) var repo | |
struct State: Equatable { | |
var string: String = "" | |
var int: Int = 0 | |
} | |
enum Action { | |
case task |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Dependencies | |
import Combine | |
import ComposableArchitecture | |
struct ContentView: View { | |
private let myStore: StoreOf<MyReducer> = Store(initialState: .init(number: 1), reducer: MyReducer()) | |
private let otherStore: StoreOf<OtherReducer> = Store(initialState: .init(number: 2), reducer: OtherReducer()) | |
var body: some View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TestType - constrained to built-in protocol, uses conditional conformance (a) | |
struct TestType<T: Error> { } | |
// Conditional conformance (b) | |
extension Array: Error where Element: Error { } | |
struct GenericType<G> { | |
// FAILS: These both segmentation fault (c) | |
func test<T>(_ value: TestType<[T]>) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Works | |
struct TestView1: View { | |
var body: some View { | |
SmartView { | |
VStack { | |
Text("random text") | |
Text("More random text") | |
} | |
} | |
} |