Skip to content

Instantly share code, notes, and snippets.

@lwakefield
Created March 1, 2016 13:04
Show Gist options
  • Save lwakefield/890313975bcf546e2b8e to your computer and use it in GitHub Desktop.
Save lwakefield/890313975bcf546e2b8e to your computer and use it in GitHub Desktop.
let Todos = new Mongo.Collection('todos');
if (Meteor.isClient) {
let App = Vue.component('app', {
template: '#app',
data() {
return {
todos: [],
newTodo: ''
}
},
methods: {
addNewTodo() {
Todos.insert({
title: this.newTodo
});
this.newTodo = '';
},
removeTodo(todo) {
Todos.remove(todo._id);
}
},
created() {
Tracker.autorun( () => this.todos = Todos.find().fetch() );
}
});
Meteor.startup(() => {
new Vue({
el: 'body',
components: {
App
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment