From 911702aa858f098fa97f2459494fb422dfa72870 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Tue, 28 May 2024 11:07:01 +0800 Subject: [PATCH] async call --- PHDemo/PHDemo/DemoToastVC.swift | 8 +++++--- Sources/ProHUD/Alert/AlertProvider.swift | 8 +++++--- Sources/ProHUD/Capsule/CapsuleProvider.swift | 8 +++++--- Sources/ProHUD/Sheet/SheetProvider.swift | 8 +++++--- Sources/ProHUD/Toast/ToastProvider.swift | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/PHDemo/PHDemo/DemoToastVC.swift b/PHDemo/PHDemo/DemoToastVC.swift index 9245347..f0a048f 100644 --- a/PHDemo/PHDemo/DemoToastVC.swift +++ b/PHDemo/PHDemo/DemoToastVC.swift @@ -55,9 +55,11 @@ class TestToast: HUDProviderType { // 详见子类中的 self.init(initializer: nil) return } - let t = Target() - initializer(t) - t.push() + Task { + let t = await Target() + initializer(t) + await t.push() + } } /// 根据ViewModel和自定义的初始化代码创建一个Target并显示 diff --git a/Sources/ProHUD/Alert/AlertProvider.swift b/Sources/ProHUD/Alert/AlertProvider.swift index 9d74123..1bf4f32 100644 --- a/Sources/ProHUD/Alert/AlertProvider.swift +++ b/Sources/ProHUD/Alert/AlertProvider.swift @@ -22,9 +22,11 @@ open class AlertProvider: HUDProviderType { // 详见子类中的 self.init(initializer: nil) return } - let t = Target() - initializer(t) - t.push() + Task { + let t = await Target() + initializer(t) + await t.push() + } } /// 根据ViewModel和自定义的初始化代码创建一个Target并显示 diff --git a/Sources/ProHUD/Capsule/CapsuleProvider.swift b/Sources/ProHUD/Capsule/CapsuleProvider.swift index 523c4b9..b0245d6 100644 --- a/Sources/ProHUD/Capsule/CapsuleProvider.swift +++ b/Sources/ProHUD/Capsule/CapsuleProvider.swift @@ -22,9 +22,11 @@ open class CapsuleProvider: HUDProviderType { // 详见子类中的 self.init(initializer: nil) return } - let t = Target() - initializer(t) - t.push() + Task { + let t = await Target() + initializer(t) + await t.push() + } } /// 根据ViewModel和自定义的初始化代码创建一个Target并显示 diff --git a/Sources/ProHUD/Sheet/SheetProvider.swift b/Sources/ProHUD/Sheet/SheetProvider.swift index 55befac..881c2d8 100644 --- a/Sources/ProHUD/Sheet/SheetProvider.swift +++ b/Sources/ProHUD/Sheet/SheetProvider.swift @@ -22,9 +22,11 @@ public final class SheetProvider: HUDProviderType { // 详见子类中的 self.init(initializer: nil) return } - let t = Target() - initializer(t) - t.push() + Task { + let t = await Target() + initializer(t) + await t.push() + } } /// 如果不存在就创建并弹出一个HUD实例,如果存在就更新实例 diff --git a/Sources/ProHUD/Toast/ToastProvider.swift b/Sources/ProHUD/Toast/ToastProvider.swift index eaf167a..19a19bb 100644 --- a/Sources/ProHUD/Toast/ToastProvider.swift +++ b/Sources/ProHUD/Toast/ToastProvider.swift @@ -22,9 +22,11 @@ open class ToastProvider: HUDProviderType { // 详见子类中的 self.init(initializer: nil) return } - let t = Target() - initializer(t) - t.push() + Task { + let t = await Target() + initializer(t) + await t.push() + } } /// 根据ViewModel和自定义的初始化代码创建一个Target并显示