Skip to content

Commit 3ab944e

Browse files
Explicitly define objectWillChange on ViewStore. (#353)
* Explicitly define `objectWillChange` on `ViewStore`. Because the `ViewStore` no longer uses `@Published` variables, the conformance to `ObservableObject` no longer sythesizes the `objectWillChange` property on `ViewStore` in iOS 13.0 or 13.1. This caused `ViewStore` changes to not propagate, leading to views never updating on these OS versions. This fixes issues #334 and (the already closed) #238. * Apply suggestions from code review * Update Sources/ComposableArchitecture/ViewStore.swift Co-authored-by: Stephen Celis <[email protected]>
1 parent 590d06d commit 3ab944e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/ComposableArchitecture/ViewStore.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public final class ViewStore<State, Action>: ObservableObject {
4848

4949
private var viewCancellable: AnyCancellable?
5050

51+
// N.B. `ViewStore` does not use a `@Published` property, so `objectWillChange`
52+
// won't be synthesized automatically. To work around issues on iOS 13 we explicitly declare it.
53+
public private(set) lazy var objectWillChange = ObservableObjectPublisher()
54+
5155
/// Initializes a view store from a store.
5256
///
5357
/// - Parameters:

0 commit comments

Comments
 (0)