Request: Add type override
Closed this issue · 5 comments
Deleted user commented
Please add a type override to the default toasty() function.
That way I can do something like this without creating 5 different functions:
function showToast(type,title,message) {
toasty({
title: title,
msg: message,
sound: true,
type: type
});
}
showToast("warning","Error: ","Something went wrong!");
Ehesp commented
Yep I can do that. Will look into it.
Although above you could do something like:
function showToast(type,title,message) {
toasty[type]({
title: title,
msg: message,
sound: true
});
}
showToast("warning","Error: ","Something went wrong!");
Also works with default.
Deleted user commented
Ah so thats how to do it. I just did toasty.type which of course did not work.
Ehesp commented
Yep :)
Not tested, but you might be able to do this to handle no types:
function showToast(title, message, type) {
toasty[type || 'default']({
title: title,
msg: message,
sound: true
});
}
showToast("Error: ","Something went wrong!");
showToast("Error: ","Something went wrong!", "warning");
Deleted user commented
Yeah that works.
Ehesp commented
Okay cool - will close this off, doing this is a better way than as a property IMO.