Browser platform
- Last Updated: March 22, 2024
- 2 minute read
- Corticon.js
- Documentation
decisionServiceBundle.js: Your obfuscated rulesbrowser.sample.js: Sample code demonstrating calling Corticon.js rulesbrowser.sample.html: Sample HTML page for testing browser deployment
The HTML page, browser.sample.html,
present a simple form where you can provide a JSON payload, invoke your rules, and see
the resulting JSON.
The wrapper, browser.sample.js,
simply invokes the rules with the payload input provided in the form.
The HTML page and wrapper are pure sample code. They just demonstrate how Corticon.js rules can be embedded into a JavaScript application running in a browser.
The browser.sample.html is ready to
run a simple page in a browser.
In the preceding image, note that the rules replaced the default shipping mode and added a message.
browser.sample.html to build your
UI around the Decision Service that you have now validated.Multiple decision services on a browser page
An integrator can put more than one Decision Services on a single HTML
page so that a set of Corticon engine execution functions are created with one execute
function per included Decision Service. In the browser bundle, the file browser.sample.multipleDS.html provides the format for
multiple decision services. In it, you see the array property corticonEngines. Each entry in the array contains an object literal with the execute function. The script inclusion order determines where in
the array a specific decision is located. The first included Decision Service is
available at index 0 window.corticonEngines[0].execute):
|
Notice the use of the await asynchronous programming
pattern.
You could specify a different configuration for each of the services.
To set up multiple Decision Services to run in one browser instance
- In Studio, generate the first package as a bundle.
- Generate the second package as a bundle with a different bundle name.
- In the second bundle's folder, rename
decisionServiceBundle.jstodecisionServiceBundle2.js, and then copy it to the browser folder of the first bundle. - Opening
browser.sample.multipleDS.htmlopens with two input and output areas for the Decision Services.
browser.sample.multipleDS.html to specify
each of the added Decision Services.When you include only one decision service, you can access the execute function with either of the following code excerpts:
|
|