Eventing: Overview - akumina/AkuminaTraining GitHub Wiki
In our code, we can leverage the built in Akumina Foundation eventing framework to easily create, fire, and handle custom events.
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>);
We will create a custom function and set it to listen to our custom event. Then we will fire our custom event.
- Download digitalworkplace.custom.js from the "/Style Library/DigitalWorkplace/JS" folder within SharePoint
- Paste the Code within digitalworkplace.custom.js
- Upload the updated digitalworkplace.custom.js to the "/Style Library/DigitalWorkplace/JS" folder within SharePoint
- Navigate to a page on your Digital Workplace site
- Flush your cache by clicking on the Akumina icon in the left rail, clicking the refresh icon, then clicking "Refresh All Cache"
- Refresh the page. The alert should fire.
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");
See the article below for a list of all out-of-the-box Akumina Foundation Events