Skip to content

Instantly share code, notes, and snippets.

@niallobrien
Created June 23, 2015 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niallobrien/6cb8390dfbc2d2ef1ed3 to your computer and use it in GitHub Desktop.
Save niallobrien/6cb8390dfbc2d2ef1ed3 to your computer and use it in GitHub Desktop.
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