我想用处理新发布的值时收到的值更新一些变量。例如,给定:
class ProductViewModel: ObservableObject {
@Published var PublishedX: Int = 0
@Published var PublishedY: Int = 0
@Published var PublishedProduct: Int = 0
// ...
init() {
productPublisher = Publishers.CombineLatest(external.XPublisher, internal.YPublisher)
// .assignAndContinue(\.PublishedX, \.PublishedY) // something like this
.flatMap(MyPublishers.secretMultiplication)
.assign(to: \.PublishedProduct, on: self)
}
}
我还想将 XPublisher 和 YPublisher 的新值分配给变量(分别为 PublishedX 和 PublishedY)。
有没有办法设置这两个变量然后继续处理事件?