forked from shakee93/vue-toasted
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reusable-toast.js
30 lines (24 loc) · 885 Bytes
/
reusable-toast.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Vue from 'vue';
import VueToasted from 'vue-toasted';
Vue.use(VueToasted, {
globalToasts : {
// have your toast name as propery name
// it should accept 2 parameters 'payload' and 'initiate' callback
// NOTE : you should return the initiate callback
myCustomError : function(payload, initiate){
// have your logic here
if(payload.someProperty == true) {
return initiate(payload.someProperty.message, 'error');
}
// initiate(Message/html, option/string)
// error/show/success/info you can pass main function names or an option object
return initiate("My Deepest Condolence", 'error');
}
}
});
// using the global toast anywhere
let toast = Vue.$toasted.global.myCustomError({
someProperty : {
message : 'a message'
}
});