Skip to content

Commit e1c7077

Browse files
committed
wip
1 parent fab3510 commit e1c7077

File tree

7 files changed

+10
-280
lines changed

7 files changed

+10
-280
lines changed

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-Lists-LoadThenNavigate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private let readMe = """
1010
"""
1111

1212
struct LoadThenNavigateListState: Equatable {
13-
var rows: IdentifiedArray<Row> = [
13+
var rows: IdentifiedArrayOf<Row> = [
1414
.init(count: 1, id: UUID()),
1515
.init(count: 42, id: UUID()),
1616
.init(count: 100, id: UUID()),

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-Lists-NavigateAndLoad.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ private let readMe = """
99
"""
1010

1111
struct NavigateAndLoadListState: Equatable {
12-
var rows: IdentifiedArray<Row> = [
12+
var rows: IdentifiedArrayOf<Row> = [
1313
.init(count: 1, id: UUID()),
1414
.init(count: 42, id: UUID()),
1515
.init(count: 100, id: UUID()),

Examples/Todos/Todos/Todos.swift

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ let appReducer = Reducer<AppState, AppAction, AppEnvironment>.combine(
7272
.eraseToEffect()
7373

7474
case .sortCompletedTodos:
75-
state.todos.sortCompleted()
75+
state.todos.sort { $1.isComplete && !$0.isComplete }
7676
return .none
7777

7878
case .todo(id: _, action: .checkBoxToggled):
@@ -152,20 +152,7 @@ struct AppView: View {
152152
}
153153
}
154154

155-
extension IdentifiedArray where ID == UUID, Element == Todo {
156-
fileprivate mutating func sortCompleted() {
157-
// Simulate stable sort
158-
self = IdentifiedArray(
159-
self.enumerated()
160-
.sorted(by: { lhs, rhs in
161-
(rhs.element.isComplete && !lhs.element.isComplete) || lhs.offset < rhs.offset
162-
})
163-
.map(\.element)
164-
)
165-
}
166-
}
167-
168-
extension IdentifiedArray where ID == UUID, Element == Todo {
155+
extension IdentifiedArray where Element == Todo, ID == Element.ID {
169156
static let mock: Self = [
170157
Todo(
171158
description: "Check Mail",

Sources/ComposableArchitecture/Internal/Deprecations.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import Combine
22
import SwiftUI
33

4-
// NB: Deprecated after TODO:
5-
6-
@available(*, unavailable, renamed: "IdentifiedArray")
7-
public typealias IdentifiedArrayOf<Element> = IdentifiedArray<Element>
8-
where Element: Identifiable
9-
104
// NB: Deprecated after 0.17.0:
115

126
extension IfLetStore {

Sources/ComposableArchitecture/Reducer.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,15 +845,14 @@ public struct Reducer<State, Action, Environment> {
845845
/// generally considered a logic error, as a child reducer cannot process a child action
846846
/// for unavailable child state.
847847
/// - Returns: A reducer that works on `GlobalState`, `GlobalAction`, `GlobalEnvironment`.
848-
public func forEach<GlobalState, GlobalAction, GlobalEnvironment>(
849-
state toLocalState: WritableKeyPath<GlobalState, IdentifiedArray<State>>,
850-
action toLocalAction: CasePath<GlobalAction, (State.ID, Action)>,
848+
public func forEach<GlobalState, GlobalAction, GlobalEnvironment, ID>(
849+
state toLocalState: WritableKeyPath<GlobalState, IdentifiedArray<ID, State>>,
850+
action toLocalAction: CasePath<GlobalAction, (ID, Action)>,
851851
environment toLocalEnvironment: @escaping (GlobalEnvironment) -> Environment,
852852
breakpointOnNil: Bool = true,
853853
_ file: StaticString = #file,
854854
_ line: UInt = #line
855-
) -> Reducer<GlobalState, GlobalAction, GlobalEnvironment>
856-
where State: Identifiable {
855+
) -> Reducer<GlobalState, GlobalAction, GlobalEnvironment> {
857856
.init { globalState, globalAction, globalEnvironment in
858857
guard let (id, localAction) = toLocalAction.extract(from: globalAction) else { return .none }
859858
if globalState[keyPath: toLocalState][id: id] == nil {

Sources/ComposableArchitecture/SwiftUI/ForEachStore.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,12 @@ where Data: Collection, ID: Hashable, Content: View {
140140
/// - store: A store on an identified array of data and an identified action.
141141
/// - content: A function that can generate content given a store of an element.
142142
public init<EachContent: View>(
143-
_ store: Store<IdentifiedArray<EachState>, (ID, EachAction)>,
143+
_ store: Store<IdentifiedArray<ID, EachState>, (ID, EachAction)>,
144144
@ViewBuilder content: @escaping (Store<EachState, EachAction>) -> EachContent
145145
)
146146
where
147-
EachState: Identifiable,
148-
ID == EachState.ID,
149147
EachContent: View,
150-
Data == IdentifiedArray<EachState>,
148+
Data == IdentifiedArray<ID, EachState>,
151149
Content == WithViewStore<
152150
OrderedSet<ID>, (ID, EachAction), ForEach<OrderedSet<ID>, ID, EachContent>
153151
>

Tests/ComposableArchitectureTests/IdentifiedArrayTests.swift

Lines changed: 0 additions & 248 deletions
This file was deleted.

0 commit comments

Comments
 (0)