Revision as of 20:18, December 15, 2015 by KrisMcG (talk | contribs)
Jump to: navigation, search

Widget Bus API Overview

The Widget Bus API comprises two components:

The Widget Bus API events and commands are analogous to standard events and methods with one main difference: events and commands are executed asynchronously utilizing deferred methods.

For the following examples, let's use the CXConsole. The CXConsole is an exposed CXBus interface that allows you to invoke commands and subscribe to events. The CXConsole is accessible globally at this location:

window._genesys.cxwidget.console

Let's assume the console is saved to the var CXConsole = window._genesys.cxwidget.console; local variable.

Example 1: Subscribing to an Event

Format: CXBusInterface.subscribe("event name and path", function(){})

Example:

CXConsole.subscribe("cx.plugin.WebChat.ready", function(){});

Example 2: Invoking a Command

Format: CXBusInterface.command("command name and path", options).done(function).fail(function)

Example:

CXConsole.command("cx.plugin.WebChat.open", {}).done(function(e){

	// success scenario

}).fail(function(e){

	// failure scenario: error, exception, improper arguments
})

Comments or questions about this documentation? Contact us for support!