mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Use a Task instead of a DispatchQueue to fix the flakey observation tests. (#4321)
When debugging in, sometimes the value hadn't been set after dispatching, whereas it has with a Task. Not sure I fully understand why and it's annoying that there aren't any observation APIs for didSet.
This commit is contained in:
@@ -20,8 +20,8 @@ extension Observable {
|
|||||||
let value = withObservationTracking {
|
let value = withObservationTracking {
|
||||||
self[keyPath: property]
|
self[keyPath: property]
|
||||||
} onChange: {
|
} onChange: {
|
||||||
// Dispatch the update as this is willSet not didSet.
|
// Handle the update on the next run loop as this is willSet not didSet.
|
||||||
DispatchQueue.main.async {
|
Task {
|
||||||
guard isActive else { return }
|
guard isActive else { return }
|
||||||
observe()
|
observe()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user