@Published and willSet vs. didSet semantics

Typically, using @Published on a property, and then subscribing to the publisher that is created will give you willSet semantics - your subscriber will be notified with the new values before the variable has actually been set.

I've observed that if my subscriber receives the notification on a different thread, such as RunLoop.main, the result is that I get didSet semantics - my subscriber is notified after the variable has been set. My question is this: how reliable is this? Can I expect this to be the case 100% of the time, or am I setting myself up for a race condition?
Post not yet marked as solved Up vote post of Mcorey Down vote post of Mcorey
1.5k views
Add a Comment