Sending and receiving events
What is a plugin without some way of interacting with the application or project being developed? In this article we cover how to work with events.
We'll assume you covered how to create a plugin in the previous articles, and that you have your code open for development. The Plugin class should already be imported, too.
Use Plugin.event to work with the .on() or .send() methods as necessary
Plugin.event.on('project-loaded', (_, project) => {
console.log('Project loaded happened!');
console.log(project);
})
Plugin.event.send('plugin-event', 5);
Now your plugin can subscribe to events and run methods accordingly, and send events to the application! Refer to the Events reference to view supported events and requests.