Skip to content

Commit e9c81e0

Browse files
committed
Bind product, customer, and status inputs
1 parent 8ad55b8 commit e9c81e0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Creation/Synchronizer/RemoteOrderSynchronizer.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ final class RemoteOrderSynchronizer: OrderSynchronizer {
4949
self.stores = stores
5050

5151
updateBaseSyncOrderStatus()
52+
bindInputs()
5253
}
5354

5455
// MARK: Methods
@@ -72,4 +73,26 @@ private extension RemoteOrderSynchronizer {
7273
self?.baseSyncStatus = baseStatus
7374
}
7475
}
76+
77+
/// Updates the underlying order as inputs are received.
78+
///
79+
func bindInputs() {
80+
setStatus.withLatestFrom(orderPublisher)
81+
.map { newStatus, order in
82+
order.copy(status: newStatus)
83+
}
84+
.assign(to: &$order)
85+
86+
setProduct.withLatestFrom(orderPublisher)
87+
.map { productInput, order in
88+
ProductInputTransformer.update(input: productInput, on: order)
89+
}
90+
.assign(to: &$order)
91+
92+
setAddresses.withLatestFrom(orderPublisher)
93+
.map { addressesInput, order in
94+
order.copy(billingAddress: addressesInput?.billing, shippingAddress: addressesInput?.shipping)
95+
}
96+
.assign(to: &$order)
97+
}
7598
}

0 commit comments

Comments
 (0)