System Services
This section describes each of the system services. Very few of the services apply to the News application, so most of the code samples in this section are simple ones to illustrate the service calls and handlers.
The system services are accessed through Mojo.Service.Request()
,
or the equivalent scene controller method this.controller.serviceRequest()
:
Mojo.Service.Request("palm://serviceName", options, requestOptions);
The arguments are described in Chapter 8, but briefly:
serviceName
Is a URI-formatted string that uniquely specifies the service name.
options
Includes the designated method, parameters, and callback functions.
requestOptions
Is either set to true, requesting automatic subscription renewal on error, or an object with a
resubscribe
property and/or auseNativeParser
property.
Warning
Be careful to prevent garbage collection of your service requests. Recall from
Chapter 8 that requests made with this.controller.serviceRequest()
are
garbage-collected and destroyed when the scene is popped. You should use
Mojo.Service.Request()
to save the
request object and handle termination of the request yourself to prevent
garbage collection.
Service requests do not complete when you make the call; they are
all asynchronous. If it’s possible
that the life of your request will outlast
the life of the assistant when the call is made, you must use
Mojo.Service.Request()
.
Get Palm webOS now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.