Skip to content
Khoa Pham@onmyway133

How to use objectWillChange in Combine

1 min read

A publisher that emits before the object has changed

Use workaround DispatchQueue to wait another run loop to access newValue

.onReceive(store.objectWillChange, perform: {
    DispatchQueue.main.async {
        self.reload()
    }
})

func reload() {
    self.isFavorite = store.isFavorite(country: country)
}

Read more

Keep reading

Type to search titles and full text.

↑ ↓ move↵ openPagefind