-
Notifications
You must be signed in to change notification settings - Fork 28
Lite API: Runtime
Parent Document: ANT APIs
Runtime API comprises of the app-lifecycle functions and miscellaneous utility functions.
You need to load runtime API module before you use its API as following.
var runtimeAPI = require('ant').runtime;
String setCurrentApp(Function on_initialize, Function on_start, Function on_stop);
setCurrentApp()
registers functions in charge of application lifecycle in App Runtime.
And it returns whether it succeeded in registering the app runtime.
-
on_initialize
: Called when installing an application. -
on_start
: Called at application startup. -
on_stop
: Called when the application program is stopped.
It returns a result
(String) of “Success” if it succeeds in registering in App Runtime and “Failed” if it fails.
var onInitialize = function () {
console.log("onInitialize");
);
var onStart = function () {
console.log('onStart');
);
var onStop = function () {
console.log('onStop');
};
runtimeAPI.setCurrentApp(onInitialize, onStart, onStop);
Object getCurrentApp();
getCurrentApp()
returns the app currently registered in the App Runtime.
If there is no registered app, undefined
is returned.
var app = runtimeAPI.getCurrentApp();
if (app != undefined) {
app.start();
app.stop();
Number getPssInKB();
getPssInKB()
returns the PSS of the currently running app.
var pss = runtimeAPI.getPssInKB();
String getEnv(String envKey);
getEnv()
returns the value of the environment variable according to envKey
.
-
envKey
: Key value of environment variable
var antRootDir = runtimeAPI.getEnv('ANT_ROOT);
Boolean downloadFileViaHTTP(String url, String downloadPath);
downloadFileViaHTTP()
downloads a file.
-
url
: URL to download -
downloadPath
: Directory to save downloaded files
It returns whether the download was successful.
var resultDownload = runtimeAPI.downloadFileViaHTTP(modelUrl, modelArchivePath);
Boolean unarchive(String archiveFilePath, String targetDirPath);
unarchive()
decompresses the file.
-
archiveFilePath
: Path to compressed file -
targetDirPath
: Directory path to decompress
It returns whether the decompression was successful.
var resultArchive = runtimeAPI.unarchive(modelArchivePath, modelDirectoryPath);
- Home
- About
- Getting Started
-
ANT APIs
- ANT Classic API
- ANT Lite API
- Getting Involved