Skip to content

Instantly share code, notes, and snippets.

@mchoiruln
Last active March 28, 2019 13:31
Show Gist options
  • Save mchoiruln/fa61cc7114da743b1d5c114a6299b012 to your computer and use it in GitHub Desktop.
Save mchoiruln/fa61cc7114da743b1d5c114a6299b012 to your computer and use it in GitHub Desktop.
Javascripts Bookmark
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
# 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