Skip to content

Commit

Permalink
Fix tutorial indentiation for diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jan 8, 2024
1 parent 1b1355c commit ae491c9
Show file tree
Hide file tree
Showing 154 changed files with 350 additions and 350 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import ComposableArchitecture

@Reducer
struct CounterFeature {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import ComposableArchitecture
@Reducer
struct CounterFeature {
struct State {

}

enum Action {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct CounterFeature {
struct State {
var count = 0
}

enum Action {
case decrementButtonTapped
case incrementButtonTapped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ struct CounterFeature {
struct State {
var count = 0
}

enum Action {
case decrementButtonTapped
case incrementButtonTapped
}

var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .decrementButtonTapped:

case .incrementButtonTapped:

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ struct CounterFeature {
struct State {
var count = 0
}

enum Action {
case decrementButtonTapped
case incrementButtonTapped
}

var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .decrementButtonTapped:
state.count -= 1
return .none

case .incrementButtonTapped:
state.count += 1
return .none
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct CounterView: View {
let store: StoreOf<CounterFeature>

var body: some View {
EmptyView()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct CounterView: View {
let store: StoreOf<CounterFeature>

var body: some View {
VStack {
Text("0")
Expand All @@ -15,7 +15,7 @@ struct CounterView: View {
.padding()
.background(Color.black.opacity(0.1))
.cornerRadius(10)

Button("+") {
}
.font(.largeTitle)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct CounterView: View {
let store: StoreOf<CounterFeature>

var body: some View {
VStack {
Text("0")
Expand All @@ -15,7 +15,7 @@ struct CounterView: View {
.padding()
.background(Color.black.opacity(0.1))
.cornerRadius(10)

Button("+") {
}
.font(.largeTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extension CounterFeature.State: Equatable {}

struct CounterView: View {
let store: StoreOf<CounterFeature>

var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
VStack {
Expand All @@ -19,7 +19,7 @@ struct CounterView: View {
.padding()
.background(Color.black.opacity(0.1))
.cornerRadius(10)

Button("+") {
viewStore.send(.incrementButtonTapped)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct MyApp: App {
static let store = Store(initialState: CounterFeature.State()) {
CounterFeature()
}

var body: some Scene {
WindowGroup {
CounterView(store: MyApp.store)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct MyApp: App {
CounterFeature()
._printChanges()
}

var body: some Scene {
WindowGroup {
CounterView(store: MyApp.store)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct CounterView: View {
let store: StoreOf<CounterFeature>

var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
VStack {
Expand All @@ -17,7 +17,7 @@ struct CounterView: View {
.padding()
.background(Color.black.opacity(0.1))
.cornerRadius(10)

Button("+") {
viewStore.send(.incrementButtonTapped)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct CounterView: View {
let store: StoreOf<CounterFeature>

var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
VStack {
Expand All @@ -17,7 +17,7 @@ struct CounterView: View {
.padding()
.background(Color.black.opacity(0.1))
.cornerRadius(10)

Button("+") {
viewStore.send(.incrementButtonTapped)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
struct CounterView: View {
let store: StoreOf<CounterFeature>

var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
VStack {
Expand All @@ -17,7 +17,7 @@ struct CounterView: View {
.padding()
.background(Color.black.opacity(0.1))
.cornerRadius(10)

Button("+") {
viewStore.send(.incrementButtonTapped)
}
Expand All @@ -33,7 +33,7 @@ struct CounterView: View {
.padding()
.background(Color.black.opacity(0.1))
.cornerRadius(10)

if viewStore.isLoading {
ProgressView()
} else if let fact = viewStore.fact {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ struct CounterFeature {
struct State: Equatable {
var count = 0
}

enum Action {
case decrementButtonTapped
case incrementButtonTapped
}

var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .decrementButtonTapped:
state.count -= 1
return .none

case .incrementButtonTapped:
state.count += 1
return .none
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ struct CounterFeature {
var fact: String?
var isLoading = false
}

enum Action {
case decrementButtonTapped
case factButtonTapped
case incrementButtonTapped
}

var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .decrementButtonTapped:
state.count -= 1
state.fact = nil
return .none

case .factButtonTapped:
state.fact = nil
state.isLoading = true
return .none

case .incrementButtonTapped:
state.count += 1
state.fact = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ struct CounterFeature {
var fact: String?
var isLoading = false
}

enum Action {
case decrementButtonTapped
case factButtonTapped
case incrementButtonTapped
}

var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .decrementButtonTapped:
state.count -= 1
state.fact = nil
return .none

case .factButtonTapped:
state.fact = nil
state.isLoading = true

let (data, _) = try await URLSession.shared
.data(from: URL(string: "http://numbersapi.com/\(state.count)")!)
// 🛑 'async' call in a function that does not support concurrency
// 🛑 Errors thrown from here are not handled

state.fact = String(decoding: data, as: UTF8.self)
state.isLoading = false

return .none

case .incrementButtonTapped:
state.count += 1
state.fact = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ struct CounterFeature {
var fact: String?
var isLoading = false
}

enum Action {
case decrementButtonTapped
case factButtonTapped
case incrementButtonTapped
}

var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .decrementButtonTapped:
state.count -= 1
state.fact = nil
return .none

case .factButtonTapped:
state.fact = nil
state.isLoading = true
return .run { send in
// ✅ Do async work in here, and send actions back into the system.
}

case .incrementButtonTapped:
state.count += 1
state.fact = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ struct CounterFeature {
var fact: String?
var isLoading = false
}

enum Action {
case decrementButtonTapped
case factButtonTapped
case incrementButtonTapped
}

var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .decrementButtonTapped:
state.count -= 1
state.fact = nil
return .none

case .factButtonTapped:
state.fact = nil
state.isLoading = true
Expand All @@ -30,7 +30,7 @@ struct CounterFeature {
.data(from: URL(string: "http://numbersapi.com/\(count)")!)
let fact = String(decoding: data, as: UTF8.self)
}

case .incrementButtonTapped:
state.count += 1
state.fact = nil
Expand Down
Loading

0 comments on commit ae491c9

Please sign in to comment.