Skip to content

Commit ae2d355

Browse files
committed
76
1 parent 5038f57 commit ae2d355

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

db.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@
9898
"completed": false,
9999
"body": "asdf",
100100
"id": 24
101+
},
102+
{
103+
"subject": "asdf",
104+
"completed": false,
105+
"body": "asdf",
106+
"id": 25
101107
}
102108
]
103109
}

src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export default {
3838
triggerToast
3939
} = useToast();
4040
41+
console.log(showToast.value);
42+
4143
return {
4244
toastMessage,
4345
toastAlertType,

src/composables/toast.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import { ref, onUnmounted } from 'vue';
1+
import { computed, onUnmounted } from 'vue';
2+
import { useStore } from 'vuex';
3+
24
export const useToast = () => {
3-
const toastMessage = ref('');
4-
const toastAlertType = ref('');
5-
const showToast = ref(false);
6-
const timeout = ref(null);
5+
const store = useStore();
6+
const toastMessage = computed(() => store.state.toastMessage);
7+
const toastAlertType = computed(() => store.state.toastAlertType);
8+
const showToast = computed(() => store.state.showToast);
9+
const timeout = computed(() => store.state.timeout);
710
const triggerToast = (message, type = 'success') => {
811
toastMessage.value = message;
912
toastAlertType.value = type;

src/store/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { createStore } from 'vuex';
22

33
export default createStore({
44
state: {
5-
5+
toastMessage: '',
6+
toastAlertType: '',
7+
showToast: false,
8+
timeout: null
69
}
710
});

0 commit comments

Comments
 (0)