title: suggestions how to keep "calculated" a lot of "dependent" parameters
body: <p>I have several indicators which need to be "always up to date". I.e. when anything is changed I need to recalculate "dependent". I have several levels where each next level should be calculated only when previous level is calculated. Let me explain by this shining picture:</p>
  
  <p><img src="https://i.stack.imgur.com/uDs3G.png" alt="Design"></p>
  
  <p>At some point Assume that Franc changed. Then we should:</p>
  
  <ol>
  <li>calc Franc / Dinar</li>
  <li>calc Franc / Dinar / Peso</li>
  </ol>
  
  <p>Or, if Peso, Franc and Dinar are changed all at once then we should:</p>
  
  <ol>
  <li>calc Franc / Dinar</li>
  <li>calc Franc / Dinar / Peso</li>
  <li>calc Peso + Euro / (Euro + Usd)</li>
  </ol>
  
  <p>So whenever anything at the <code>Level 0</code> is chagned we should recalculate all other levels. But</p>
  
  <ul>
  <li>we should calculate only required items. If Euro changed we do not need to recalculate Franc / Dinar</li>
  <li>we should not calculate anything more than once. if Euro and Usd are changed at once we should calculate Euro + Usd only once (not twice).</li>
  </ul>
  
  <p>The most straightforward solution would be:</p>
  
  <ul>
  <li>store each level in array</li>
  <li>for each item in array track "listeners" from next levels (could be difficulty because for example Peso has listeners from different levels - Franc / Dinar / Peso from Level2 and Peso + Euro / (Euro + Usd) from Level 3, so two-dimmension array is required..)</li>
  <li>if item is recalculated then mark all it listeners to be recalculated too</li>
  <li>go from Level 0 to last level and recalculate items that marked to be recalculated (initially updated items are market to be recalculated, for example Peso).</li>
  </ul>
  
  <p>I guess that my problem is kind of well-known and probably you can suggest me general well-known solution. I don't want to reinvent the wheel :) Thanks!</p>