vue-settimeout

0.0.9 • Public • Published

/*!

  • Vue-setTimeout
  • (c) 2018 +v
  • Released under the MIT License. / / */

var $setTimeout = function (code, millisec, isSetInterval) { // setTimeout var i = isSetInterval === true ? setInterval(code, millisec) : setTimeout(code, millisec) // in case of beforeDestroy is undefined (if "destroyed" not set, in prod mode) if (!this.$options['destroyed']) { this.$options['destroyed'] = [] } // add clearTimeout to hook "destroyed" isSetInterval ? this.$options['destroyed'].unshift(function () { // clearInterval on vue component destroy clearInterval(i) }) : this.$options['destroyed'].unshift(function () { // clearTimeout on vue component destroy clearTimeout(i) }) }

export default { install: function (Vue) { Object.defineProperty(Vue.prototype, '$setTimeout', {value: $setTimeout}) } }

Dependents (0)

Package Sidebar

Install

npm i vue-settimeout

Weekly Downloads

1

Version

0.0.9

License

MIT

Unpacked Size

20.2 kB

Total Files

8

Last publish

Collaborators

  • chiaweilee