pjs.requireServiceProgram()

pjs.requireServiceProgram()

Description

This method is used to load a Profound.js module as a Service Program. When loaded this way, functions from the target module – as well as functions from additional modules loaded by the target module – will be exported.

Parameters

  1. Module path / name - A String containing the module file name to load. Optionally, an absolute path or a path relative to the modules directory can be used. If only the file name is given, the pathlist will be searched to locate the module. If the file extension is omitted, .js is assumed.

  2. Options (optional) - An object with the following properties:

    • hotReload - Set to Boolean false if the module should not be reloaded when the file has changed, and should instead be loaded only once for the duration of the Profound.js process. This setting overrides the global hotReloading setting.

Exception Handling

An Error will be thrown if there are any problems loading the module, such as a file not found or a syntax error.

Examples

Calling Module

// Caller. Loading mydir/mySrvpgm.js as a service program exports the functions // of that module AND the functions of every module it loads. exports.activationGroup = "Named1"; // named activation group for this program const mySrvpgm = pjs.requireServiceProgram("mydir/mySrvpgm"); // Exported functions can be called through the returned object: mySrvpgm.myFunction(); // They are also attached to the scope that called pjs.requireServiceProgram(), // so calling them directly is equally valid: myFunction();

Service Program Module – mydir/mySrvpgm.js

mydir/mySrvpgm.js
// The service program itself. It defines no functions of its own -- it simply // pulls in the modules whose functions should be exported to the caller. exports.activationGroup = "Named1"; pjs.requireModule("module1"); pjs.requireModule("module2"); pjs.requireModule("module3");