StevenLambion / SwiftDux

Predictable state management for SwiftUI applications.
http://stevenlambion.github.io/SwiftDux
MIT License
153 stars 10 forks source link

Fix Stale UI When Using ActionDispatcher In Some Cases #23

Closed StevenLambion closed 4 years ago

StevenLambion commented 4 years ago

This PR fixes cases where the View fails to refresh correctly after dispatching an action. The exact cause is unknown, but is due to internal implementation details of SwiftUI.

To fix this problem, the actionDispatcher is now added to the MappedState itself as an environment value. It's unused by MappedState, but SwiftUI will still attach subscribers to it. This replaces the manual subscription that published updates to the corresponding StateConnection<_>. For some unknown reason, this would stop working after one or more refreshes.

codecov-io commented 4 years ago

Codecov Report

Merging #23 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff          @@
##           master   #23   +/-   ##
====================================
  Coverage      60%   60%           
====================================
  Files          15    15           
  Lines         410   410           
====================================
  Hits          246   246           
  Misses        164   164

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 83be78d...ed85493. Read the comment docs.