Skip to content

Commit 983808d

Browse files
committed
feat: call delete action from internal action instead from view action
1 parent 0b986cd commit 983808d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

{{cookiecutter.app_name}}/Features/Sources/Counter/CounterFeature.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public struct Counter: FeatureReducer {
2323
public enum ViewAction: Equatable {
2424
case decrementButtonTapped
2525
case incrementButtonTapped
26+
case closeButtonTapped
27+
}
28+
29+
public enum InternalAction: Equatable {
30+
case close
2631
}
2732

2833
public enum DelegateAction: Equatable {
@@ -38,6 +43,16 @@ public struct Counter: FeatureReducer {
3843
case .incrementButtonTapped:
3944
state.count += 1
4045
return .none
46+
47+
case .closeButtonTapped:
48+
return .send(.internal(.close))
49+
}
50+
}
51+
52+
public func reduce(into state: inout State, internalAction: InternalAction) -> Effect<Action> {
53+
switch internalAction {
54+
case .close:
55+
return .send(.delegate(.close))
4156
}
4257
}
4358
}

{{cookiecutter.app_name}}/Features/Sources/Counter/CounterView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public struct CounterView: View {
3939
}
4040

4141
Button {
42-
viewstore.send(.delegate(.close))
42+
viewstore.send(.view(.closeButtonTapped))
4343
} label: {
4444
Text("Dismiss")
4545
.foregroundStyle(.white)

0 commit comments

Comments
 (0)