monokee/Sekoia

Computed Properties: Dependency resolution bug

Opened this issue · 3 comments

Stumbled upon the following case:

Update county -> Changes Tax -> recalculate total
Update quantity -> changes priceBeforeDiscount & tax

  • priceBeforeDiscount -> changes subTotal -> changes total
  • Tax -> changes total

In this case Total is computed from subtotal (computed from priceBeforeDiscount + tax)
and Tax (not computed).
So subtotal needs to be resolved before total. Current implementation is buggy b/c total is recalculated first.

possibly related to synchronous handling -> #12

still buggy after async implementation in v1.04-beta

Store events can be executed in a nested queue to ensure compatibility between Component bindings and external handlers bound via Store.subscribe. This mechanism can lead to the evaluation of stale computations from the prior reaction loop.

To fix, simply add Store Events to their own dedicated Reactor Queue and unpack it prior to resolving computations and executing callbacks. This way, if a Store Event adds its own computations or callbacks because it has been bound via Components, they will be correctly evaluated in a single reaction loop.

Fixed in v.1.05-beta