UNPKG

@millicast/vue-viewer-plugin

Version:

Vue.js plugin to embed viewer of a Millicast stream. This plugin allows developers to simplify Millicast services integration into their own Vue.js apps.

61 lines (52 loc) 1.24 kB
import { useToast } from 'vue-toastification' import store from '../../../src/store' const TYPE = { SUCCESS: "success", ERROR: "error", WARNING: "warning", INFO: "info" } class CustomToast { constructor() { this.toast = useToast() this.store = store } showToast(type, message, options) { this.toast = useToast() this.toast.clear() if (this.shouldShowError(type)) { this.showToaster(type, message, options) } } showToaster(type, message, options) { switch (type) { case TYPE.ERROR: this.toast.error(message,options) break case TYPE.WARNING: this.toast.warning(message,options) break case TYPE.INFO: this.toast.info(message,options) break case TYPE.SUCCESS: this.toast.success(message,options) break default: break } } shouldShowError(type) { const hideToast = this.store?._state?.data?.Controls.hideToast return !(hideToast ? hideToast.includes(type) : false) } clear() { this.toast = useToast() this.toast.clear() } updateDefaults(options) { this.toast = useToast() this.toast.updateDefaults(options) } } export default CustomToast