Skip to content

Commit

Permalink
Refactor dispatch function definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Qata committed Jul 23, 2021
1 parent 215c0f2 commit d3e310f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Sources/RecombinePackage/Store/BaseStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,23 @@ public class BaseStore<State: Equatable, RawAction, RefinedAction>: StoreProtoco
maxPublishers: maxPublishers,
recurse(actions:)
)
let transformed: AnyPublisher<[RefinedAction], Never>

if collect {
recursed
transformed = recursed
.collect()
.map { $0.flatMap { $0 } }
.sink {
self?._preMiddlewareRefinedActions.send($0)
}
.store(in: &cancellables)
.eraseToAnyPublisher()
} else {
recursed
.sink {
self?._preMiddlewareRefinedActions.send($0)
}
.store(in: &cancellables)
transformed = recursed
.eraseToAnyPublisher()
}

transformed
.sink {
self?._preMiddlewareRefinedActions.send($0)
}
.store(in: &cancellables)
}

open func injectBypassingMiddleware<S: Sequence>(actions: S) where S.Element == RefinedAction {
Expand Down

0 comments on commit d3e310f

Please sign in to comment.