Last active
March 28, 2019 13:31
-
-
Save mchoiruln/fa61cc7114da743b1d5c114a6299b012 to your computer and use it in GitHub Desktop.
Javascripts Bookmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrayRotateOne(arr, reverse){ | |
if(reverse) | |
arr.unshift(arr.pop()) | |
else | |
arr.push(arr.shift()) | |
return arr | |
} | |
# Source : https://stackoverflow.com/questions/1985260/javascript-array-rotate/33451102#33451102 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/questions/36572540/vue-js-auto-reload-refresh-data-with-timer | |
data: function() { | |
return { | |
list: [], | |
timer: '' | |
} | |
}, | |
created: function() { | |
this.fetchEventsList(); | |
this.timer = setInterval(this.fetchEventsList, 300000) | |
}, | |
methods: { | |
fetchEventsList: function() { | |
this.$http.get('events', function(events) { | |
this.list = events; | |
}).bind(this); | |
}, | |
cancelAutoUpdate: function() { clearInterval(this.timer) } | |
}, | |
beforeDestroy() { | |
clearInterval(this.timer) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment