Shobhit Sharma edited this page Nov 16, 2017 · 8 revisions

Embedo has internal event listeners implemented which emits following events:

Private Events

.done() and .fail() chain

These events are always attached to each embedo .load() call instance. They act much like promises for .done() to resolve or .fail() to catch error in chain.


Global Events

Event Dispatchers Description
watch on/once/off When an element has loaded or size is modified in DOM
refresh on/once/off When a refresh event is finished
destroy on/once/off When embedo instance(s) are destroyed
error on/once/off Exception handler happened during embed

During lifecycle of Embedo class, all instances are stored in memory to emit and handle necessary events for DOM. They listen to any change in size, destroyed or refreshed instances all in once place. The arguments contain meta data which helps to log and understand which particular instance has been called.

embedo.on('watch', (request) => {});
embedo.on('refresh', (request, data) => {});
embedo.on('destroy', (request) => {});
embedo.on('error', (error) => {});

window.postMessage Listener (⚠️ deprecated v1.7.3 onwards)

To listen to each time embedo renders an element successfully, it can also be decoded through:

window.addEventListener('message', function (event) {
  if ( && Array.isArray( &&'embedo') !== -1) {
    var decoded_message = JSON.parse([2]);
    console.log(event, decoded_message);
}, false);
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.