Eventing: Overview - akumina/AkuminaTraining GitHub Wiki

Overview

In our code, we can leverage the built in Akumina Foundation eventing framework to easily create, fire, and handle custom events.

Subscribe

When we 'Subscribe' to an event, we specify a function that will listen for the event. To subscribe to an event we will use the format below

Akumina.Digispace.AppPart.Eventing.Subscribe('<EventName>', <FunctionName>);

Publish When we 'Publish' an event, we fire it. To Publish an event we will use the format below

Akumina.Digispace.AppPart.Eventing.Publish('<EventName>');

Publish an event with data

Akumina.Digispace.AppPart.Eventing.Publish('<EventName>', <Data>);

Sample

We will create a custom function and set it to listen to our custom event. Then we will fire our custom event.

How to Deploy

  1. Download digitalworkplace.custom.js from the "/Style Library/DigitalWorkplace/JS" folder within SharePoint
  2. Paste the Code within digitalworkplace.custom.js
  3. Upload the updated digitalworkplace.custom.js to the "/Style Library/DigitalWorkplace/JS" folder within SharePoint
  4. Navigate to a page on your Digital Workplace site
  5. Flush your cache by clicking on the Akumina icon in the left rail, clicking the refresh icon, then clicking "Refresh All Cache"
  6. Refresh the page. The alert should fire.

Code

function SampleFunction(data) 
{
	alert('Custom event fired with ' + data);
}

Akumina.Digispace.AppPart.Eventing.Subscribe('/sample/coolevent/', SampleFunction);

Akumina.Digispace.AppPart.Eventing.Publish('/sample/coolevent/',  "Really cool input");

References

See the article below for a list of all out-of-the-box Akumina Foundation Events

⚠️ **GitHub.com Fallback** ⚠️