Skip to content

Commit bad761c

Browse files
hj56775hanjun-yu
and
hanjun-yu
authored
Add Store.send(_ action:) return StoreTask (#2323)
Co-authored-by: hanjun-yu <[email protected]>
1 parent 382e44f commit bad761c

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

Sources/ComposableArchitecture/Store.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ public final class Store<State, Action> {
190190
/// store is available, prefer ``ViewStore/send(_:)``.
191191
///
192192
/// - Parameter action: An action.
193-
public func send(_ action: Action) {
194-
_ = self.send(action, originatingFrom: nil)
193+
@discardableResult
194+
public func send(_ action: Action) -> StoreTask {
195+
.init(rawValue: self.send(action, originatingFrom: nil))
195196
}
196197

197198
/// Sends an action to the store with a given animation.

Sources/ComposableArchitecture/SwiftUI/Alert.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ extension View {
4646
}
4747
case let .animatedSend(action, animation):
4848
if let action = action {
49-
withAnimation(animation) {
50-
store.send(.presented(fromDestinationAction(action)))
51-
}
49+
store.send(.presented(fromDestinationAction(action)), animation: animation)
5250
}
5351
}
5452
} label: {

Sources/ComposableArchitecture/SwiftUI/ConfirmationDialog.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ extension View {
5151
}
5252
case let .animatedSend(action, animation):
5353
if let action = action {
54-
withAnimation(animation) {
55-
store.send(.presented(fromDestinationAction(action)))
56-
}
54+
store.send(.presented(fromDestinationAction(action)), animation: animation)
5755
}
5856
}
5957
} label: {

0 commit comments

Comments
 (0)