@@ -93,7 +93,8 @@ public struct DiffableTextField<Style: DiffableTextStyle>: UIViewRepresentable {
9393 // MARK: State
9494 //=--------------------------------------------------------------------=
9595
96- @usableFromInline let lock = Lock ( )
96+ @usableFromInline let lock = Lock ( )
97+ @usableFromInline var update = Update ( )
9798
9899 @usableFromInline var cache : Cache !
99100 @usableFromInline var context : Context !
@@ -265,32 +266,40 @@ public struct DiffableTextField<Style: DiffableTextStyle>: UIViewRepresentable {
265266 //=----------------------------------=
266267 // Upstream, Downstream
267268 //=----------------------------------=
268- Status ( upstream. style, upstream. value. wrappedValue , downstream. focus)
269+ Status ( upstream. style, upstream. value, downstream. focus)
269270 }
270271
271272 @inlinable func push( _ update: Update ) {
273+ //=----------------------------------=
274+ // State
275+ //=----------------------------------=
276+ self . update += update
277+ //=----------------------------------=
278+ // Value
279+ //=----------------------------------=
280+ if let _ = self . update. remove ( . value) {
281+ self . upstream. value = self . context. value
282+ //=------------------------------=
283+ // Reentrance
284+ //=------------------------------=
285+ return
286+ }
272287 //=----------------------------------=
273288 // Lock
274289 //=----------------------------------=
275290 self . lock. perform {
276291 //=------------------------------=
277292 // Text
278293 //=------------------------------=
279- if update. contains ( . text) {
294+ if let _ = self . update. remove ( . text) {
280295 self . downstream. text = context. text
281296 }
282297 //=------------------------------=
283298 // Selection
284299 //=------------------------------=
285- if update. contains ( . selection) {
300+ if let _ = self . update. remove ( . selection) {
286301 self . downstream. selection = context. selection ( )
287302 }
288- //=------------------------------=
289- // Value
290- //=------------------------------=
291- if update. contains ( . value) {
292- self . upstream. value. wrappedValue = context. value
293- }
294303 }
295304 }
296305 }
0 commit comments