The problem is that the add or subtract method of the Holder class could are run asynchronously in the same tick, resulting in the following:
balance = 100
add(10); => balance is 100, adding 10, new balance is 110, schedule BalanceUpdateEvent for next tick;
add(20); => balance is still 100 since its still the same tick, adding 20, new balance is 120, schedule BalanceUpdateEvent for next tick;
-- next tick --
setting balance to 110
setting balance to 120 => first add is ignored"
related pull request: #16
If there is a better solution to this, please do implement that, this was the fastest and easiest way I could think of how to fix it.
I have made an alternative pull request #18 that addresses this issue by making the events able to run in an async thread instead of synchronising them to the main thread.
The problem is that the add or subtract method of the Holder class could are run asynchronously in the same tick, resulting in the following:
balance = 100
add(10); => balance is 100, adding 10, new balance is 110, schedule BalanceUpdateEvent for next tick; add(20); => balance is still 100 since its still the same tick, adding 20, new balance is 120, schedule BalanceUpdateEvent for next tick;
-- next tick --
setting balance to 110 setting balance to 120 => first add is ignored"
related pull request: #16 If there is a better solution to this, please do implement that, this was the fastest and easiest way I could think of how to fix it.