Using webOS Features

Built-in webOS Events

Included within the webOS system itself are the following custom document events:

enyo-webos

The enyo-webos library has a number of features designed exclusively for the webOS platform. These include components that make webOS service calls easier to manage, as well as Enyo signal generation for the webOS events mentioned above.

ServiceRequest and LunaService

Two components that allow for integration of webOS services into Enyo applications are enyo-webos/ServiceRequest and enyo-webos/LunaService. They may be viewed as being analogous to enyo/Ajax and enyo/WebService, respectively.

ServiceRequest is based on enyo/Async; the constructor takes the service name, method, parameters, and an optional subscription flag.

    var
        ServiceRequest = require('enyo-webos/ServiceRequest');

    var request = new ServiceRequest({
        service: 'luna://com.palm.connectionmanager',
        method: 'getstatus'
    });
    request.response(this, function (sender, response) {
        // service request succeeded with returned data within response
    });
    request.go({});

Building upon this, LunaService provides a reusable component for interacting with webOS services.

    var
        kind = require('enyo/kind'),
        LunaService = require('enyo-webos/LunaService');

    module.exports = kind({
        name: "App",
        components: [
            {name: 'netstat', kind: LunaService, service: 'luna://com.palm.connectionmanager',
                method: 'getstatus', onResponse: 'serviceResponse'},
            ...
        ],
        getConnectionStatus: function () {
            var request = this.$.netstat.send({});
        },
        serviceResponse: function (sender, response) {
            // service request succeeded with returned data within response
        }
    });

webOS.js

In much the same way that enyo-cordova includes the standalone Cordova library, enyo-webos includes the standalone webOS.js library. webOS.js focuses on providing webOS-specific functionality in a streamlined package, with support for both Open webOS and webOS for TV in a single API set. Included in webOS.js are the following modules: