diff --git a/Sources/Feedbacks/System/Feedback.swift b/Sources/Feedbacks/System/Feedback.swift index 4be477a..0ec7d48 100644 --- a/Sources/Feedbacks/System/Feedback.swift +++ b/Sources/Feedbacks/System/Feedback.swift @@ -18,25 +18,10 @@ public struct Feedback { case cancelOnNewState case continueOnNewState - func apply( - on sideEffect: @escaping (StateType) -> AnyPublisher, + func apply( + on sideEffect: @escaping (Input) -> AnyPublisher, willExecuteWithStrategy: @escaping (Feedback.Strategy) -> Void = { _ in } - ) -> (AnyPublisher) -> AnyPublisher { - return { states in - willExecuteWithStrategy(self) - switch self { - case .cancelOnNewState: - return states.map(sideEffect).switchToLatest().eraseToAnyPublisher() - case .continueOnNewState: - return states.flatMap(sideEffect).eraseToAnyPublisher() - } - } - } - - func apply( - on sideEffect: @escaping (State) -> AnyPublisher, - willExecuteWithStrategy: @escaping (Feedback.Strategy) -> Void = { _ in } - ) -> (AnyPublisher) -> AnyPublisher { + ) -> (AnyPublisher) -> AnyPublisher { return { states in willExecuteWithStrategy(self) switch self {