Difference between revisions of "JavaScript Services"

From WebOS Internals
Jump to navigation Jump to search
m
m
Line 2: Line 2:
  
 
== Node versions ==
 
== Node versions ==
* webOS 2: node v0.2.3
+
* webOS 1.x: node not present
 +
* webOS 2.x: node v0.2.3
 
* webOS 3.0: node v0.4.12
 
* webOS 3.0: node v0.4.12
 
* webOS TV: ?
 
* webOS TV: ?
* LuneOS (webOS 3.5): node v0.10.?
+
* LuneOS (webOS 3.5): node v0.10.25
  
  
Line 11: Line 12:
 
To return a success, set future.result to an object with the desired properties (where future is the future passed to the Command Assistant).
 
To return a success, set future.result to an object with the desired properties (where future is the future passed to the Command Assistant).
  
To return a failure, set future.exception to an object (typically some kind of Error). If you set the errorCode property of the object, that
+
To return a failure, set future.exception to an object (often some kind of Error). Best practice is to set both '''message''' and '''errorCode''' properties.
will be the errorCode returned over PalmBus, and the errorText will be copied from the message property.  Otherwise, errorCode will be -9999 and errorText will be "MojoService: no errorCode supplied "+(reply.errorText||"")
+
 
 +
(If you set the errorCode property of the object, that
 +
will be the errorCode returned over PalmBus, and the errorText will be copied from the message property.  Otherwise, errorCode will be -9999 and errorText will be "MojoService: no errorCode supplied "+(reply.errorText||""))
  
  
 
While the Command Assistant run() method is called "inside" the future, it's not clear that you can compose the passed future with others.
 
While the Command Assistant run() method is called "inside" the future, it's not clear that you can compose the passed future with others.

Revision as of 15:45, 13 October 2014

Some notes to flesh out the primary documentation

Node versions

  • webOS 1.x: node not present
  • webOS 2.x: node v0.2.3
  • webOS 3.0: node v0.4.12
  • webOS TV: ?
  • LuneOS (webOS 3.5): node v0.10.25


Values returned over the PalmBus

To return a success, set future.result to an object with the desired properties (where future is the future passed to the Command Assistant).

To return a failure, set future.exception to an object (often some kind of Error). Best practice is to set both message and errorCode properties.

(If you set the errorCode property of the object, that will be the errorCode returned over PalmBus, and the errorText will be copied from the message property. Otherwise, errorCode will be -9999 and errorText will be "MojoService: no errorCode supplied "+(reply.errorText||""))


While the Command Assistant run() method is called "inside" the future, it's not clear that you can compose the passed future with others.