Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Template.todo.onCreated(function() {
var template = this;
template.limit = new ReactiveVar(5);
});
Template.todo.rendered = function () {
var template = this;
Vue.use(window['vue-validator']);
var vm = new Vue({
el: '#demo',
data: {
title: 'todos',
todos: [],
newTodo: '',
limit: template.limit.get(),
loading: false
},
methods: {
addTodo: function (e) {
e.preventDefault()
if (this.newTodo.trim()) {
Meteor.call('addTodo', this.newTodo)
this.newTodo = ''
}
},
removeTodo: function (id) {
Meteor.call('removeTodo', id)
},
loadMore: function() {
console.log(template.subscriptionsReady());
Meteor.setTimeout(function() {
template.limit.set(template.limit.get() + 5)
}, 5000)
},
},
created: function () {
this.subscription = Meteor.subscribe('todos', function() {
});
},
sync: {
'todos': function() {
return Todos.find({}, {limit: template.limit.get()});
},
'loading': function() {
return template.subscriptionsReady();
}
},
destroyed: function () {
this.subscription.stop()
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.