JavaScript Plugins

The Haplo Platform provides a server side JavaScript plugin API, allowing you to write plugins which implement custom functionality in your Haplo application.

You can read and write data in the object store, use relational database storage, respond to HTTP requests, add to the home page and object pages, extend the Haplo user interface, implement work flow, and more.

During development, you use the Plugin Tool to upload your plugin and automated tests to a test server.

Have a look at Contacts button for an example of a simple plugin.

Isolation and sandboxing

Each Haplo application is completely isolated from each other, and the JavaScript API carefully restricts access.

Every call to a platform API is checked to make sure it’s valid, and the capabilities of the API are carefully designed to provide safe operation within a shared environment.

Runtimes

All the plugins installed in a Haplo application are loaded into and run in a single shared JavaScript runtime. As it can take over 50ms to load a plugin, runtimes are kept in memory but idle between request processing.

There may be more than one JavaScript runtime for each application, if this is required to support concurrent requests for a busy application. However, Haplo tries to minimise the number of JavaScript runtimes for an application by slightly delaying request handling when other requests are being processed.

Because concurrency is managed by the Platform, you don’t have to worry about complex multi-threaded programming.

In the very rare cases where you need to take into account multiple runtimes, you can use the InterRuntimeSignal to communicate between them.

Speed and efficiency

The Haplo Platform is designed to be very fast, and be as responsive as a desktop application. The plugin API is designed to make it easy for you to use the same principles as used for the main Platform, and maintain the responsiveness of the platform for our clients.

Limits are placed on the amount of processing and data that can be accessed to ensure fast responses to all requests.

Coding style

The JavaScript coding style used for the plugin API is a little different to the simple use of JavaScript in web pages. If you’d like a quick update on modern JavaScript, here’s a couple of recommendations for short books:

JavaScript: The Good PartsDouglas Crockford

JavaScript PatternsStoyan Stefanov