UNPKG

@shopgate/engage

Version:
11 lines 1.37 kB
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{UIEvents}from"../../../core";import{EVENT_LIVE_MESSAGE,LIVE_MESSAGE_TYPE_POLITE}from"./constants";/** * Broadcasts a live message to a LiveMessenger component. * @param {string} message The message. * @param {Object} options Additional options. * @param {string} options.type Type of the message * @param {Object} options.params Message params for an i18n placeholder message. * @param {string} options.id Id of the LiveMessenger component which sets the message. * @param {boolean} options.force If set to TRUE the LiveMessenger component will read the text, * even if the same was broadcasted before. */export function broadcastLiveMessage(message){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var defaults={type:LIVE_MESSAGE_TYPE_POLITE,params:null,id:null};if(!message){return;}var params=_extends({},defaults,{},options);UIEvents.emit(EVENT_LIVE_MESSAGE,message,params);setTimeout(function(){// Clear the live area after a short time, so that the screen reader can't focus the element. UIEvents.emit(EVENT_LIVE_MESSAGE,'',params);},100);}