Skip to content

Commit ceb6c2b

Browse files
authored
Merge pull request #37 from CombineCommunity/improve/feedback-apply
feedback: remove duplicate apply
2 parents e948f9b + c6d0771 commit ceb6c2b

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

Sources/Feedbacks/System/Feedback.swift

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,10 @@ public struct Feedback {
1818
case cancelOnNewState
1919
case continueOnNewState
2020

21-
func apply<StateType: State>(
22-
on sideEffect: @escaping (StateType) -> AnyPublisher<Event, Never>,
21+
func apply<Input, Output>(
22+
on sideEffect: @escaping (Input) -> AnyPublisher<Output, Never>,
2323
willExecuteWithStrategy: @escaping (Feedback.Strategy) -> Void = { _ in }
24-
) -> (AnyPublisher<StateType, Never>) -> AnyPublisher<Event, Never> {
25-
return { states in
26-
willExecuteWithStrategy(self)
27-
switch self {
28-
case .cancelOnNewState:
29-
return states.map(sideEffect).switchToLatest().eraseToAnyPublisher()
30-
case .continueOnNewState:
31-
return states.flatMap(sideEffect).eraseToAnyPublisher()
32-
}
33-
}
34-
}
35-
36-
func apply(
37-
on sideEffect: @escaping (State) -> AnyPublisher<Event, Never>,
38-
willExecuteWithStrategy: @escaping (Feedback.Strategy) -> Void = { _ in }
39-
) -> (AnyPublisher<State, Never>) -> AnyPublisher<Event, Never> {
24+
) -> (AnyPublisher<Input, Never>) -> AnyPublisher<Output, Never> {
4025
return { states in
4126
willExecuteWithStrategy(self)
4227
switch self {

0 commit comments

Comments
 (0)