Not sure if it is proper, but I use define call with the page's route. I put this in my client.js.
define('admin/plugins/plugin-id', function () { // 'admin/plugins/plugin-id' is the route for the admin page
return { init: function(){
// do stuff here, like call socket.emit, and setup settings as normal.
}};
});
I usually require a separate module, so that the full script isn't loaded on every page load.
define('admin/plugins/plugin-id', function () {
return { init: function () {
require(['/route/to/plugin/js/acp.js'], function (acp) {
acp.doThings();
});
}};
});
acp.js
define(['settings', 'translator'], function (settings, translator) {
var acp = { };
acp.doThings = function () {
// This is where I would call socket.emit('mySocketEvent') so that I can get the additional data I need.
};
return acp;
});
I'm certain this is not the best way to do it, and the additional require is not necessary now that we have acpScripts now. There was some other reason I separated the scripts too, i don't remember at the moment.