Skip to content

Commit 7b37b2b

Browse files
ntnmrndnmuukii
andauthored
Add async variant (#178)
Co-authored-by: Muukii <[email protected]>
1 parent efc79e3 commit 7b37b2b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Sources/FluidStack/ViewController/FluidStackController.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ open class FluidStackController: UIViewController {
216216
/**
217217
Removes the view controller displayed on most top.
218218
*/
219+
@MainActor
219220
public func removeLastViewController(
220221
transition: AnyRemovingTransition?,
221222
completion: @MainActor @escaping (RemovingTransitionContext.CompletionEvent) -> Void = { _ in }
222223
) {
223224

224-
assert(Thread.isMainThread)
225-
226225
guard let wrapperView = stackingItems.last else {
227226
Log.error(.stack, "The last view controller was not found to remove")
227+
completion(.succeeded)
228228
return
229229
}
230230

@@ -236,6 +236,21 @@ open class FluidStackController: UIViewController {
236236
)
237237
}
238238

239+
@MainActor
240+
public func removeLastViewController(
241+
transition: AnyRemovingTransition?
242+
) async -> RemovingTransitionContext.CompletionEvent {
243+
244+
await withCheckedContinuation { continuation in
245+
246+
removeLastViewController(transition: transition) { event in
247+
continuation.resume(returning: event)
248+
}
249+
}
250+
251+
}
252+
253+
239254
/**
240255
Add a view controller to display.
241256
This is a primitive operation to add view controller to display.

0 commit comments

Comments
 (0)