2022-07-04 changelog

Miro Web SDK 2.0: use the off property to unsubscribe from events.

Summary

New feature: unsubscribe from Web SDK events.

What has changed

The on property enables subscribing your app to Web SDK events.

Now, the app can use the off property to unsubscribe from an event, when the app no longer needs to listen to it to trigger the corresponding event handler.

Unsubscribing from events performs the required household and cleanup actions under the hood.

Example

// Add an 'iconClick' event handler to open a panel upon clicking an icon.
const iconClick = async () => {
  await miro.board.ui.openPanel({
    url: 'panel.html',
  });
};

// Register the 'icon:click' event, so that the app listens to it.
miro.board.ui.on('icon:click', iconClick);

// Unsubscribe from the 'icon:click' event handler.
// The app no longer enables opening a panel when clicking an icon.
miro.board.ui.off('icon:click', iconClick);