A condition type library module has one goal: evaluate whether something is true or false. What it evaluates is up to you.
Let’s assume we wish to evaluate whether the user is on the host adobelaunch.com
. Our module may look like this:
module.exports = (context) => {
const URL = context.arc.event.xdm.web.webpageDetails.URL;
return URL.endsWith("adobelaunch.com");
};
Simple enough. Now what if we wanted to make the hostname configurable by the Launch user? In our view we would allow the user to input a hostname and then save the hostname to the settings object. The object might look something like this:
{
"hostname": "example.com"
}
In order to operate on the user-defined hostname, our module would need to change to this:
module.exports = (context) => {
const URL = context.arc.event.xdm.web.webpageDetails.URL;
return URL.endsWith(settings.hostname);
};
The result returned by a condition module can be:
true
or false
.All condition modules have access to a context
variable that is provided when the module is called. You can learn more here.