Skip to content

Lite API: Runtime

Hayun Lee edited this page Dec 21, 2020 · 8 revisions

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;

App Lifecycle

setCurrentApp()

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.

Example

var onInitialize = function () {
  console.log("onInitialize");
);
var onStart = function () {
  console.log('onStart');
);
var onStop = function () {
  console.log('onStop');
};

runtimeAPI.setCurrentApp(onInitialize, onStart, onStop);

Misc. Utility