File tree Expand file tree Collapse file tree 1 file changed +4
-29
lines changed
Sources/ComposableArchitecture/Beta Expand file tree Collapse file tree 1 file changed +4
-29
lines changed Original file line number Diff line number Diff line change @@ -218,35 +218,10 @@ import SwiftUI
218218 /// - Parameter predicate: A predicate on `State` that determines for how long this method
219219 /// should suspend.
220220 public func suspend( while predicate: @escaping ( State ) -> Bool ) async {
221- let cancellable = Box < AnyCancellable ? > ( wrappedValue: nil )
222- try ? await withTaskCancellationHandler (
223- handler: { cancellable. wrappedValue? . cancel ( ) } ,
224- operation: {
225- try Task . checkCancellation ( )
226- try await withUnsafeThrowingContinuation {
227- ( continuation: UnsafeContinuation < Void , Error > ) in
228- guard !Task. isCancelled else {
229- continuation. resume ( throwing: CancellationError ( ) )
230- return
231- }
232- cancellable. wrappedValue = self . publisher
233- . filter { !predicate( $0) }
234- . prefix ( 1 )
235- . sink { _ in
236- continuation. resume ( )
237- _ = cancellable
238- }
239- }
240- }
241- )
242- }
243- }
244-
245- private class Box < Value> {
246- var wrappedValue : Value
247-
248- init ( wrappedValue: Value ) {
249- self . wrappedValue = wrappedValue
221+ _ = await self . publisher
222+ . values
223+ . filter { !predicate( $0) }
224+ . first ( where: { _ in true } )
250225 }
251226 }
252227#endif
You can’t perform that action at this time.
0 commit comments