JSFiddle - React, Tailwind, and code Playground

by Thorsten

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.0-beta.1/vue.js"></script>
<div id="app">
  <button @click="run">Run loooong function</button>
  <p v-if="show">this should be shown immeadiatly after clicking, and disappear after 3 seconds</p>
</div>

Babel + JSX

function sleepFor( sleepDuration ){
    var now = new Date().getTime();
    while(new Date().getTime() < now + sleepDuration){ /* do nothing */ } 
}

var app = new Vue({
  el: '#app',
  data: { test: 'Test', show: false},
  methods: {
    run() {
      this.show = true
      setTimeout(function () {
      	sleepFor(3000)
      	this.show = false
      }.bind(this),0)
      
    }
  }
})