diff --git a/Package.resolved b/Package.resolved index 730f67e..4cf3365 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/combine-schedulers", "state" : { - "revision" : "aa3e575929f2bcc5bad012bd2575eae716cbcdf7", - "version" : "0.8.0" + "revision" : "9dc9cbe4bc45c65164fa653a563d8d8db61b09bb", + "version" : "1.0.0" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-case-paths", "state" : { - "revision" : "bb436421f57269fbcfe7360735985321585a86e5", - "version" : "0.10.1" + "revision" : "5da6989aae464f324eef5c5b52bdb7974725ab81", + "version" : "1.0.0" } }, { @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-clocks", "state" : { - "revision" : "692ec4f5429a667bdd968c7260dfa2b23adfeffc", - "version" : "0.1.4" + "revision" : "d1fd837326aa719bee979bdde1f53cd5797443eb", + "version" : "1.0.0" } }, { @@ -59,8 +59,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-composable-architecture", "state" : { - "revision" : "1fcd53fc875bade47d850749ea53c324f74fd64d", - "version" : "0.45.0" + "revision" : "f62ba37cc0c51acb89f6dd1f552f6a1f9c58027c", + "version" : "1.1.0" + } + }, + { + "identity" : "swift-concurrency-extras", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-concurrency-extras", + "state" : { + "revision" : "ea631ce892687f5432a833312292b80db238186a", + "version" : "1.0.0" } }, { @@ -68,8 +77,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-custom-dump", "state" : { - "revision" : "819d9d370cd721c9d87671e29d947279292e4541", - "version" : "0.6.0" + "revision" : "edd66cace818e1b1c6f1b3349bb1d8e00d6f8b01", + "version" : "1.0.0" + } + }, + { + "identity" : "swift-dependencies", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-dependencies", + "state" : { + "revision" : "4e1eb6e28afe723286d8cc60611237ffbddba7c5", + "version" : "1.0.0" } }, { @@ -77,8 +95,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-identified-collections", "state" : { - "revision" : "bfb0d43e75a15b6dfac770bf33479e8393884a36", - "version" : "0.4.1" + "revision" : "d1e45f3e1eee2c9193f5369fa9d70a6ddad635e8", + "version" : "1.0.0" + } + }, + { + "identity" : "swiftui-navigation", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swiftui-navigation", + "state" : { + "revision" : "f5bcdac5b6bb3f826916b14705f37a3937c2fd34", + "version" : "1.0.0" } }, { @@ -86,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", "state" : { - "revision" : "16e6409ee82e1b81390bdffbf217b9c08ab32784", - "version" : "0.5.0" + "revision" : "23cbf2294e350076ea4dbd7d5d047c1e76b03631", + "version" : "1.0.2" } } ], diff --git a/Package.swift b/Package.swift index cd93444..aa75fcc 100644 --- a/Package.swift +++ b/Package.swift @@ -13,7 +13,7 @@ let package = Package( targets: ["TCALogsSheetKit"]), ], dependencies: [ - .package(url: "https://github.com/pointfreeco/swift-composable-architecture", from: "0.45.0"), + .package(url: "https://github.com/pointfreeco/swift-composable-architecture", from: "1.1.0"), .package(url: "https://github.com/riiid/LogsSheetKit", from: "1.0.0") ], targets: [ diff --git a/Sources/TCALogsSheetKit/Examples/CounterReducer.swift b/Sources/TCALogsSheetKit/Examples/CounterReducer.swift index 9ecdfbb..ba1d90c 100644 --- a/Sources/TCALogsSheetKit/Examples/CounterReducer.swift +++ b/Sources/TCALogsSheetKit/Examples/CounterReducer.swift @@ -9,7 +9,7 @@ import ComposableArchitecture import Foundation import LogsSheetKit -struct Counter: ReducerProtocol { +struct Counter: Reducer { struct State: Equatable { var logs: [ActionLog] = [] var count = 0 @@ -21,7 +21,7 @@ struct Counter: ReducerProtocol { } - var body: some ReducerProtocol { + var body: some Reducer { Reduce { (state, action) in switch action { case .increase: diff --git a/Sources/TCALogsSheetKit/Examples/CounterView.swift b/Sources/TCALogsSheetKit/Examples/CounterView.swift index 4c25e8a..40cf703 100644 --- a/Sources/TCALogsSheetKit/Examples/CounterView.swift +++ b/Sources/TCALogsSheetKit/Examples/CounterView.swift @@ -15,7 +15,10 @@ struct CounterView: View { @State private var isPresented: Bool = false var body: some View { - WithViewStore(self.store) { store in + WithViewStore( + self.store, + observe: { $0 } + ) { store in NavigationView { VStack { Spacer() @@ -49,9 +52,12 @@ struct CounterView: View { struct CounterView_Previews: PreviewProvider { static var previews: some View { - CounterView(store: Store( - initialState: Counter.State(), - reducer: Counter() - )) + CounterView( + store: .init( + initialState: Counter.State(), + reducer: { + Counter() + }) + ) } } diff --git a/Sources/TCALogsSheetKit/TCALogger.swift b/Sources/TCALogsSheetKit/TCALogger.swift index 682dfe8..d095f92 100644 --- a/Sources/TCALogsSheetKit/TCALogger.swift +++ b/Sources/TCALogsSheetKit/TCALogger.swift @@ -10,41 +10,11 @@ import Foundation import ComposableArchitecture import LogsSheetKit -extension AnyReducer { +extension Reducer { /// Saves each action run through the reducer as the log message if debug build configuration is on /// - Parameters: /// - isDebug: is debug configuration on - public func log(isDebug: Bool) -> Self { - AnyReducer.init { state, action, environment in - if isDebug { - LogsSheetManager.shared.log(message: "\(action)") - } - return self.run(&state, action, environment) - } - } - - /// Saves the custom log message if debug build configuration is on - /// - Parameters: - /// - isDebug: is debug configuration on - /// - message: custom log message - public func log( - isDebug: Bool, - with message: @escaping ((Action) -> String) - ) -> Self { - AnyReducer.init { state, action, environment in - if isDebug { - LogsSheetManager.shared.log(message: message(action)) - } - return self.run(&state, action, environment) - } - } -} - -extension ReducerProtocol { - /// Saves each action run through the reducer as the log message if debug build configuration is on - /// - Parameters: - /// - isDebug: is debug configuration on - public func log(isDebug: Bool) -> some ReducerProtocol { + public func log(isDebug: Bool) -> some Reducer { Reduce { state, action in if isDebug { LogsSheetManager.shared.log(message: "\(action)") @@ -60,7 +30,7 @@ extension ReducerProtocol { public func log( isDebug: Bool, with message: @escaping ((Action) -> String) - ) -> some ReducerProtocol { + ) -> some Reducer { Reduce { state, action in if isDebug { LogsSheetManager.shared.log(message: message(action)) diff --git a/TCALoggerSample/TCALoggerSample/Counter/Counter.swift b/TCALoggerSample/TCALoggerSample/Counter/Counter.swift index a11c140..6c3343c 100644 --- a/TCALoggerSample/TCALoggerSample/Counter/Counter.swift +++ b/TCALoggerSample/TCALoggerSample/Counter/Counter.swift @@ -9,12 +9,12 @@ import ComposableArchitecture import Dependencies import TCALogsSheetKit -public struct Counter: ReducerProtocol { +public struct Counter: Reducer { @Dependency(\.serviceCounter) private var serviceCounter public init() {} - public var body: some ReducerProtocol { + public var body: some Reducer { Reduce { state, action in switch action { case .increase: diff --git a/TCALoggerSample/TCALoggerSample/Counter/CounterView.swift b/TCALoggerSample/TCALoggerSample/Counter/CounterView.swift index 111dd8f..af1422b 100644 --- a/TCALoggerSample/TCALoggerSample/Counter/CounterView.swift +++ b/TCALoggerSample/TCALoggerSample/Counter/CounterView.swift @@ -19,7 +19,10 @@ public struct CounterView: View { @State private var isPresented: Bool = false public var body: some View { - WithViewStore(self.store) { store in + WithViewStore( + self.store, + observe: { $0 } + ) { store in NavigationView { VStack(spacing: 20) { Spacer() @@ -80,8 +83,9 @@ public struct CounterView: View { struct CounterView_Previews: PreviewProvider { static var previews: some View { CounterView(store: Store( - initialState: Counter.State(), - reducer: Counter() - )) + initialState: Counter.State() + ) { + Counter() + }) } } diff --git a/TCALoggerSample/TCALoggerSample/Emoji/EmojiPicker.swift b/TCALoggerSample/TCALoggerSample/Emoji/EmojiPicker.swift index e1ca239..74d48de 100644 --- a/TCALoggerSample/TCALoggerSample/Emoji/EmojiPicker.swift +++ b/TCALoggerSample/TCALoggerSample/Emoji/EmojiPicker.swift @@ -8,12 +8,12 @@ import ComposableArchitecture import Dependencies -public struct EmojiPicker: ReducerProtocol { +public struct EmojiPicker: Reducer { @Dependency(\.serviceBackgroundChanger) private var serviceBackgroundChanger public init() {} - public var body: some ReducerProtocol { + public var body: some Reducer { Reduce { state, action in switch action { case .changeEmoji: diff --git a/TCALoggerSample/TCALoggerSample/Emoji/EmojiPickerView.swift b/TCALoggerSample/TCALoggerSample/Emoji/EmojiPickerView.swift index 22e2874..fd1a61a 100644 --- a/TCALoggerSample/TCALoggerSample/Emoji/EmojiPickerView.swift +++ b/TCALoggerSample/TCALoggerSample/Emoji/EmojiPickerView.swift @@ -12,22 +12,24 @@ import ComposableArchitecture // MARK: - View public struct EmojiPickerView: View { - @ObservedObject - private var viewStore: ViewStoreOf private let store: StoreOf public init(store: StoreOf) { - self.viewStore = .init(store) self.store = store } public var body: some View { - VStack(spacing: 20) { - if let currentEmojie = viewStore.currentEmoji { - Text("\(currentEmojie.rawValue)") - } - Button("change emoji") { - viewStore.send(.changeEmoji) + WithViewStore( + store, + observe: \.currentEmoji + ) { viewStore in + VStack(spacing: 20) { + if let currentEmojie = viewStore.state { + Text("\(currentEmojie.rawValue)") + } + Button("change emoji") { + viewStore.send(.changeEmoji) + } } } } @@ -42,7 +44,8 @@ struct EmojiPicker_Previews: PreviewProvider { } static let store: StoreOf = .init( - initialState: .init(), - reducer: EmojiPicker() - ) + initialState: .init() + ) { + EmojiPicker() + } } diff --git a/TCALoggerSample/TCALoggerSample/TCALoggerSampleApp.swift b/TCALoggerSample/TCALoggerSample/TCALoggerSampleApp.swift index 786eeb9..338cdab 100644 --- a/TCALoggerSample/TCALoggerSample/TCALoggerSampleApp.swift +++ b/TCALoggerSample/TCALoggerSample/TCALoggerSampleApp.swift @@ -13,7 +13,13 @@ import ComposableArchitecture struct TCALoggerSampleApp: App { var body: some Scene { WindowGroup { - CounterView(store: Store(initialState: Counter.State(), reducer: Counter())) + CounterView( + store: Store( + initialState: Counter.State() + ) { + Counter() + } + ) } } } diff --git a/TCALogsSheetExample.xcworkspace/xcshareddata/swiftpm/Package.resolved b/TCALogsSheetExample.xcworkspace/xcshareddata/swiftpm/Package.resolved index 08ad1b6..d602ae2 100644 --- a/TCALogsSheetExample.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/TCALogsSheetExample.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/combine-schedulers", "state" : { - "revision" : "882ac01eb7ef9e36d4467eb4b1151e74fcef85ab", - "version" : "0.9.1" + "revision" : "9dc9cbe4bc45c65164fa653a563d8d8db61b09bb", + "version" : "1.0.0" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-case-paths", "state" : { - "revision" : "c3a42e8d1a76ff557cf565ed6d8b0aee0e6e75af", - "version" : "0.11.0" + "revision" : "5da6989aae464f324eef5c5b52bdb7974725ab81", + "version" : "1.0.0" } }, { @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-clocks", "state" : { - "revision" : "20b25ca0dd88ebfb9111ec937814ddc5a8880172", - "version" : "0.2.0" + "revision" : "d1fd837326aa719bee979bdde1f53cd5797443eb", + "version" : "1.0.0" } }, { @@ -59,8 +59,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-composable-architecture", "state" : { - "revision" : "6cf778a7da64de9508596a435aa0a5647885d71a", - "version" : "0.49.2" + "revision" : "f62ba37cc0c51acb89f6dd1f552f6a1f9c58027c", + "version" : "1.1.0" + } + }, + { + "identity" : "swift-concurrency-extras", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pointfreeco/swift-concurrency-extras", + "state" : { + "revision" : "ea631ce892687f5432a833312292b80db238186a", + "version" : "1.0.0" } }, { @@ -68,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-custom-dump", "state" : { - "revision" : "ead7d30cc224c3642c150b546f4f1080d1c411a8", - "version" : "0.6.1" + "revision" : "edd66cace818e1b1c6f1b3349bb1d8e00d6f8b01", + "version" : "1.0.0" } }, { @@ -77,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-dependencies", "state" : { - "revision" : "7a094fcc6a4fcb34fbe625ecd3acd81b881a6dfb", - "version" : "0.1.3" + "revision" : "4e1eb6e28afe723286d8cc60611237ffbddba7c5", + "version" : "1.0.0" } }, { @@ -86,8 +95,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-identified-collections", "state" : { - "revision" : "fd34c544ad27f3ba6b19142b348005bfa85b6005", - "version" : "0.6.0" + "revision" : "d1e45f3e1eee2c9193f5369fa9d70a6ddad635e8", + "version" : "1.0.0" } }, { @@ -95,8 +104,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swiftui-navigation", "state" : { - "revision" : "ddc01cdcddfd30ef7a966049b2e1d251e224ad93", - "version" : "0.5.0" + "revision" : "f5bcdac5b6bb3f826916b14705f37a3937c2fd34", + "version" : "1.0.0" } }, { @@ -104,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", "state" : { - "revision" : "16b23a295fa322eb957af98037f86791449de60f", - "version" : "0.8.1" + "revision" : "23cbf2294e350076ea4dbd7d5d047c1e76b03631", + "version" : "1.0.2" } } ],