Sekoia icon indicating copy to clipboard operation
Sekoia copied to clipboard

Computed Properties: Dependency resolution bug

Open monokee opened this issue 5 years ago • 3 comments
trafficstars

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.

monokee avatar Jan 16 '20 10:01 monokee

possibly related to synchronous handling -> #12

monokee avatar Jan 18 '20 16:01 monokee

still buggy after async implementation in v1.04-beta

monokee avatar Jan 18 '20 17:01 monokee

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

monokee avatar Jan 21 '20 12:01 monokee