Take an example of a voting DApp. A user clicks on a vote button, then behind the scenes the transaction containing the vote gets mined on the blockchain. The DApp then wants to alert('You have voted').
Since the transaction takes some time to get mined and get some confirmations, what code should the DApp do before it does the alert? I have heard of people running loops and calling getTransactionReceipt. Is this how it should be done, or alternatives? Are there any code snippets or libraries for them?
alertis just for example purpose ;) Upvoting but code snippets would be more helpful for readers. Also, "callback is typically called twice"? Snippet for detecting both cases would be helpful. – eth Feb 09 '16 at 11:09.sendTransaction()only calls the callback once (the callback for.newis what is called twice). http://ethereum.stackexchange.com/questions/7407/when-is-a-transaction-callback-called – eth Jul 25 '16 at 03:52