Event Handling

This page introduces how to attach handlers to various kumaneko events.

Register Event Handlers

Syntax
pd.event.on(appID, type, handler)
Parameters
Parameter Value Description
appID String

The app ID to which the event handler will bind to.

For events related to the dashboard, fix it to "0".

type String or Array of Strings The event type or array of event types, to which the event handler will bind to.
handler Function(Object)

The handler that will run when the event is triggered.

By returning a Promise object in the event handler, it waits for the asynchronous process to complete before starting the next process.

Response
None
Sample
((APP_ID) => {
	"use strict";
	const handler = (event) => {
		console.log(event);
	};
	pd.event.on(APP_ID, 'pd.view.load', handler);
})(pd.APP_ID);

Remove Event Handlers

Syntax
pd.event.off(appID, type, handler)
Parameters
Parameter Value Description
appID String

The app ID to which the event handler is bound to.

For events related to the dashboard, fix it to "0".

type String or Array of Strings The event type or array of event types, to which the event handler is bound to.
handler Function(Object)

The handler that will be removed from the specified event type(s).

Response
None
Sample
((APP_ID) => {
	"use strict";
	const handler = (event) => {
		console.log(event);
	};
	pd.event.on(APP_ID, 'pd.view.load', handler);

	pd.event.off(APP_ID, 'pd.view.load', handler);
})(pd.APP_ID);