@@ -188,7 +188,8 @@ public class BaseStore<State: Equatable, RawAction, RefinedAction>: StoreProtoco
188
188
)
189
189
}
190
190
191
- open func _replay< S: Sequence > ( _ values: S ) where S. Element == ( offset: Double , actions: [ RefinedAction ] ) {
191
+ open func replay< S: Sequence > ( _ values: S ) where S. Element == ( offset: Double , actions: [ RefinedAction ] ) {
192
+ dispatchEnabled = false
192
193
values
193
194
. publisher
194
195
. flatMap { offset, actions in
@@ -197,30 +198,15 @@ public class BaseStore<State: Equatable, RawAction, RefinedAction>: StoreProtoco
197
198
scheduler: DispatchQueue . global ( )
198
199
)
199
200
}
200
-
201
- values. dropLast ( )
202
- . publisher
203
- }
204
-
205
- open func replay< S: Sequence > ( _ values: S ) -> AnyPublisher < [ RefinedAction ] , Never >
206
- where S. Element == ( offset: Double , actions: [ RefinedAction ] )
207
- {
208
- values
209
- . publisher
210
- . flatMap { offset, actions in
211
- Just ( actions) . delay (
212
- for: . seconds( max ( 0 , offset) ) ,
213
- scheduler: DispatchQueue . global ( )
214
- )
215
- }
216
- . handleEvents (
217
- receiveSubscription: { _ in self . dispatchEnabled = false } ,
218
- receiveOutput: _postMiddlewareRefinedActions. send,
219
- receiveCompletion: { _ in self . dispatchEnabled = true } ,
220
- receiveCancel: { self . dispatchEnabled = true }
221
- )
222
201
// Cancel if dispatch is manually reenabled.
223
202
. prefix ( untilOutputFrom: $dispatchEnabled. filter { $0 } )
224
- . eraseToAnyPublisher ( )
203
+ . print ( " REPLAY:: " )
204
+ . sink (
205
+ receiveCompletion: { _ in
206
+ self . dispatchEnabled = true
207
+ } ,
208
+ receiveValue: _postMiddlewareRefinedActions. send
209
+ )
210
+ . store ( in: & cancellables)
225
211
}
226
212
}
0 commit comments