Skip to content

Commit 479aabb

Browse files
committed
Use .task instead of .onAppear
1 parent 16fe318 commit 479aabb

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesDebugView.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ struct InAppPurchasesDebugView: View {
1313
List {
1414
Section {
1515
Button("Reload products") {
16-
loadProducts()
16+
Task {
17+
await loadProducts()
18+
}
1719
}
1820
}
1921
Section("Products") {
@@ -37,19 +39,17 @@ struct InAppPurchasesDebugView: View {
3739
}
3840
}
3941
.navigationTitle("IAP Debug")
40-
.onAppear {
41-
loadProducts()
42+
.task {
43+
await loadProducts()
4244
}
4345
}
4446

45-
private func loadProducts() {
46-
Task {
47-
do {
48-
self.products = try await inAppPurchasesForWPComPlansManager.fetchProducts()
49-
await loadUserEntitlements()
50-
} catch {
51-
print("Error loading products: \(error)")
52-
}
47+
private func loadProducts() async {
48+
do {
49+
self.products = try await inAppPurchasesForWPComPlansManager.fetchProducts()
50+
await loadUserEntitlements()
51+
} catch {
52+
print("Error loading products: \(error)")
5353
}
5454
}
5555

0 commit comments

Comments
 (0)