Using the Java and JavaScript APIs

An Equo application usually consists of a Java and a JavaScript part. There are cases in which an Equo application looks like a pure Java application (with only a few lines of JavaScript code), and there are other cases in which it’s very rich in JavaScript, but only with a few lines of Java code. To support all the specific scenarios, Equo provides a set of Java and JavaScript APIs.

Below, a brief description about how the APIs can be consumed:

  • The Java API can be used from the Java code.

  • There is a JavaScript API that is shipped with the Equo SDK, globally available for its usage in the namespace window.equo. You don’t have to do anything to use it.

  • The JavaScript API is also bundled in Node.js packages. You will have to import the library that you want and use it as a normal Node.js package.

Using JavaScript APIs as Node.js Packages

If you are developing a complete web application for the frontend of your Equo application, it is useful to import and consume the Equo JavaScript APIs as Node.js packages.

For a reference of all JavaScript APIs, click here.

Requirements

Install Npm version above 6.0.0.

Login to the Equo Registry

Run the following command to set the Equo Npm registry:

npm config set '@equo:registry' https://registry.equo.dev/

Using the JavaScript API

To add a JavaScript API to your project, open a terminal on the root folder of your web application and execute the following command:

yarn add @equo/logging

or, if you are using just npm:

npm install @equo/logging

Importing the JavaScript API

In your JS script files, import the API:

import { logging } from '@equo/logging'

You’re ready to use it.