Skip to content

Commit 77dc305

Browse files
committed
15180 Explain task use for posModel creation
1 parent 4e34cd2 commit 77dc305

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

WooCommerce/Classes/POS/Presentation/PointOfSaleEntryPointView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ struct PointOfSaleEntryPointView: View {
3535
}
3636
}
3737
.task {
38+
// We create the posModel in a task, not init, to avoid creating multiple copies during the view's lifecycle.
39+
// Confusingly, init can be called more than once, but `task` matches the lifecycle.
40+
// See https://developer.apple.com/documentation/swiftui/state#Store-observable-objects for details.
3841
posModel = PointOfSaleAggregateModel(
3942
itemsController: itemsController,
4043
cardPresentPaymentService: cardPresentPaymentService,

0 commit comments

Comments
 (0)