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:
serviceNameIs a URI-formatted string that uniquely specifies the service name.
optionsIncludes the designated method, parameters, and callback functions.
requestOptionsIs either set to true, requesting automatic subscription renewal on error, or an object with a
resubscribeproperty and/or auseNativeParserproperty.
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().
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access