I have been developing a Vue application that allows users to convert between fiat currency and cryptocurrencies. You can try the app out for yourself here: Demo.
One interesting feature of the app is that the conversion calculation happens automatically in real-time as you type, displaying the result in the other input box. However, I've encountered an issue where the calculation only occurs when changes are made to the input variables.
In addition to updating on user input, I also want the calculation to happen when a different option is selected from the dropdown menu.
I've been struggling to find a solution without creating an endless loop in the process.
My initial attempt to solve the problem can be found here: codepen.
From my understanding, the current issue arises because:
...input1 changes -> watch input1 called -> watch input1 modifies
input2 -> watch input2 called -> watch input2 modifies input1....
This creates an infinite loop situation. It seems there's a specific aspect of Vue.js that I haven't mastered yet to address this particular challenge.
Thank you for your help,