Repeated diamonds shape

The repeated diamonds shape problem is an another pitfall of reactive programming. It is typical for straightforward reactive library implementations. It describes a situation when an update to one reactive variable causes multiple updates to another.

For example suppose we use a straightforward reactive library and have the following dependency graph with 2 "diamonds"

Then if we update the "source", the "target" will be updated 4 times. If had n "diamonds" the "target" would be updated 2n times.

Why does it matter? For example, if we do an AJAX call to the server on each variable update, then we flood it with extra queries, moreover, all queries but the last deliver inconsistent data, so if the last query fails we end with corrupted model on the server.

Knockout Reactive Coffee Warp9