From 82de6c49e5fa5b836b01bf18c4ce6a9bcdd54716 Mon Sep 17 00:00:00 2001
From: donal <donalspring@gmail.com>
Date: Sun, 01 Apr 2018 02:41:19 +0200
Subject: [PATCH] WIP - adding the vuex state stuff

---
 src/views/Catalog.vue |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/views/Catalog.vue b/src/views/Catalog.vue
index 1a55b1d..07d9112 100644
--- a/src/views/Catalog.vue
+++ b/src/views/Catalog.vue
@@ -4,7 +4,12 @@
     <NewTodo placeholderMsg="Add a new todo" @NEWTODOADDED="newTodoAdded"/>
     <TodoItem todoItem="Have a beers"/>
     <ListOfTodos todos="this.todos"/>
+
+    <button @click=newTodoAdded>add todo</button>
+    <button>getTodos</button>  
+    <code>{{ allTodos }}</code>
   </div>
+
 </template>
 
 <script>
@@ -16,7 +21,6 @@
 
 import EventBus from "@/services/EventBus";
 
-
 export default {
   name: "Catalog",
   components: {
@@ -24,9 +28,20 @@
     TodoItem,
     ListOfTodos
   },
+    // load todos on start
+  created () {
+    this.$store.dispatch('loadTodos')
+  },
+    // be able to get the data
+  computed: {
+    allTodos () {
+      return this.$store.getters.todos
+    },
+  },
   methods: {
-    newTodoAdded (e) {
-      console.info('INFO - ', e)
+    newTodoAdded(e) {
+      console.info("INFO - ", e);
+      
     }
   }
 };

--
Gitblit v1.9.3