WebApps 2


events are available in a client side context so trigger and listen to events triggered by any WebApp within a page.

import events from "@sitevision/api/common/events";


events.trigger(key [, data...])

Trigger a global event within the page.

// Trigger a global event

// Trigger a global event with data
events.trigger("add:items", 3, 'banana');

events.on(key, () => {})

Listen to a global event within the page

// Listen to an event
events.on("add:item", () => {
   console.log("Item added");
   // Item added

// Listen to an event with data
events.on("add:items", (count, item) => {
   console.log(`Added ${count} ${item}`);
   // Added 3 banana