Skip to content

2.5.1

Latest

Choose a tag to compare

@NikSativa NikSativa released this 20 Nov 19:50

removeDuplicates() on a DiffedValue publisher of ManagedState, UIState, or their bindings no longer drops an emission that changes the observed value.

Since 2.4.3, == compared the new values of two emissions. new reads the current value of the source, so two emissions of one source always had equal new values. Thus removeDuplicates() dropped a real change when the previous emission had the same old value. The failure occurred with $state.ui.list, observe(_:), map(keyPath:), safe(_:default:), and unsafe(_:).

Now ManagedState, UIState, and their bindings emit values that store the new value at the time of the emission:

  • == and hash(into:) compare old and this stored value. A later change of the source does not change the result.
  • new still reads the current value of the source.
  • A DiffedValue from a public initializer does not store its new value. The initializers do not call get, as in 2.5.0. For such a value, == and hash(into:) read new.