Skip to content

Commit

Permalink
chore(example): add toggle button to check leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Nov 24, 2017
1 parent db90cb0 commit d5e021b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
-->

<div id="app">
<button @click="toggleTodos">Toggle todos</button>
<br/>
<input
v-model.trim="newTodoText"
@keyup.enter="addTodo"
Expand Down Expand Up @@ -55,7 +57,9 @@
databaseURL: 'https://vue-fire-store.firebaseio.com'
})
const db = firebase.firestore()
var todos = db.collection('todos')
const todos = db.collection('todos')
const unFinishedTodos = todos.where('finished', '==', false)
const finishedTodos = todos.where('finished', '==', true)
const config = db.collection('configs').doc('jORwjIykFo2NmkdzTkhU')

new Vue({
Expand All @@ -65,10 +69,12 @@
config: null,
newTodoText: ''
},

firestore: {
todos: todos.where('finished', '==', false),
todos: unFinishedTodos,
config
},

methods: {
addTodo: function () {
if (this.newTodoText) {
Expand All @@ -85,6 +91,15 @@
},
removeTodo: function (todo) {
todos.doc(todo.id).delete()
},
toggleTodos () {
console.log(this.$firestoreRefs.todos === unFinishedTodos)
this.$bind(
'todos',
this.$firestoreRefs.todos === unFinishedTodos
? finishedTodos
: unFinishedTodos
)
}
}
})
Expand Down

0 comments on commit d5e021b

Please sign in to comment.