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 framework, 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.equoplatform.com

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.