File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed
Sources/ComposableArchitecture Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,35 @@ public final class ViewStore<State, Action> {
99
99
#endif
100
100
self . _state = $0
101
101
self . statePipe. input. send ( value: $0)
102
- }
102
+ }
103
103
}
104
104
105
- /// A producer of state.
106
- public var produced : StoreProducer < State > {
105
+ /// A publisher that emits when state changes.
106
+ ///
107
+ /// This publisher supports dynamic member lookup so that you can pluck out a specific field in
108
+ /// the state:
109
+ ///
110
+ /// ```swift
111
+ /// viewStore.publisher.alert
112
+ /// .sink { ... }
113
+ /// ```
114
+ ///
115
+ /// When the emission happens the ``ViewStore``'s state has been updated, and so the following
116
+ /// precondition will pass:
117
+ ///
118
+ /// ```swift
119
+ /// viewStore.publisher
120
+ /// .sink { precondition($0 == viewStore.state) }
121
+ /// ```
122
+ ///
123
+ /// This means you can either use the value passed to the closure or you can reach into
124
+ /// `viewStore.state` directly.
125
+ ///
126
+ /// - Note: Due to a bug in Combine (or feature?), the order you `.sink` on a publisher has no
127
+ /// bearing on the order the `.sink` closures are called. This means the work performed inside
128
+ /// `viewStore.publisher.sink` closures should be completely independent of each other.
129
+ /// Later closures cannot assume that earlier ones have already run.
130
+ public var produced : StoreProducer < State > {
107
131
StoreProducer ( viewStore: self )
108
132
}
109
133
You can’t perform that action at this time.
0 commit comments