im, just using Vue.js to update posts on the im messing around site, this is what ive got so far (I'm still learning javascript and not too big in it)
[app.js]
var Vue = require('vue'); Vue.use(require('vue-resource')); var app = new Vue({ el: '#app', components: { 'postlist' : require('./components/postlist/postlist.js') } });
[postlist.js]
module.exports = { template: require('./postlist.template.html'), data: function () { return { 'search': '', 'posts' : {} } }, methods: { 'updatePosts' : function() { this.$http.get('api/posts', function(responce, status, request) { this.$set('posts', responce.data); }); } } };
What I'm looking for is for updatePosts to fire every x seconds, how do I do this?
ive tried to do this in app.js
setInterval(function() { app.components.postlist.methods.updatePosts(); // doesnt work app.postlist.updatePosts(); //doesnt work either }, 500);
and tried to put setInterval in the component itself
im pretty lost with this, what is the best way to achieve this?
does updatePosts work every x seconds?
Jimmy howe
source share