View on GitHub

guides

Fresh data should propagate across the whole UI

Background

One of the tell-tale signs of well-designed data handling layer: fresh data propagates across the whole UI without having to maintain all the links manually.

From the user’s perspective - if I save my To Do item I expect this change to propagate automatically to all other pieces of the UI. 

From the developer’s perspective - I expect it to just work if I add a new UI component or if I add a new place that allows me to edit this To Do item.

If I don’t have to know the implementation details behind the propagation - I won’t forget to add something I didn’t know I had to add in the first place :)

Rules

How to test this behavior?

Always check your UI components for their behavior when underlying data is changed by another component.

Make sure this logic is not mixed up with the UI layer - it should be reasonable transparent, so that a new person can add a new UI component easily, without having to know anything.

Check the behavior when the changes are cancelled (as in hit ‘cancel’ in the object edit component). These should not be propagated.

Check the behaviors of lists when an object is added / removed. They should also update automatically!

Check the behavior of components that show the object whenever this object is removed while the component is shown.

Check if your ‘refetch-if-stale’ implementation doesn’t cause too many refetches for the same object. Always batch them up.

Implementation hints

global cache