Vue

by Martin Sandstrom

HTML

<div id="app">
  <h2>Alert on stop typing:</h2>
  <ol>
    <input type="text" @keyup="textSearch($event)">
  </ol>
</div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

Vue

new Vue({
  el: "#app",
  data: {
    timer: undefined
  },
  methods: {
    textSearch(e){
        clearTimeout(this.timer)

        this.timer = setTimeout(() => {
            alert('searching...')
        }, 2500)
      }
  }
})