01.06.2013 Views

OpenEdge Development: Mobile Applications - Product ...

OpenEdge Development: Mobile Applications - Product ...

OpenEdge Development: Mobile Applications - Product ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4: Creating <strong>Mobile</strong> Apps using JSDOs<br />

• Returning data and information from JSDO local storage:<br />

– getData( ) — Called on a JSDO table reference, this method returns an<br />

array of record objects for a referenced temp-table; has no effect on existing<br />

working record settings.<br />

– getId( ) — Called on a JSDO table reference or a JSRecord reference, this<br />

method returns the unique internal record ID for the specified record object;<br />

has no effect on existing working record settings.<br />

– getSchema( ) — Called on a JSDO table reference, this method returns an<br />

array of objects, one for each field, that defines the schema of the referenced<br />

temp-table; has no effect on existing working record settings.<br />

These methods always execute synchronously.<br />

• Managing JSDO event subscriptions:<br />

– subscribe( ) — Subscribes a given event handler function to a named<br />

event on a JSDO or on a JSDO table reference; has no effect on existing<br />

working record settings.<br />

– unsubscribe( ) — Unsubscribes a given event handler function from a<br />

named event on a JSDO or on a JSDO table reference; has no effect on<br />

existing working record settings.<br />

These methods are called on the JSDO or on a JSDO table reference, and<br />

execute synchronously. For more information on JSDO events and managing<br />

JSDO event subscriptions, see the “Asynchronous and synchronous execution”<br />

section on page 98.<br />

Asynchronous and synchronous execution<br />

As described in the previous section, most JSDO methods execute synchronously,<br />

which means that the <strong>Mobile</strong> App waits for the method to complete execution before<br />

executing the next JavaScript statement or evaluating the next term of an expression.<br />

When method execution completes and returns its results, the <strong>Mobile</strong> App continues<br />

with the next JavaScript operation.<br />

However, the JSDO fill( ) and saveChanges( ) methods, which execute built-in<br />

<strong>Mobile</strong> operations, always execute asynchronously, and any non-built-in invocation<br />

methods, which execute non-built-in <strong>Mobile</strong> invoke operations, execute<br />

asynchronously by default, but can optionally execute synchronously. Asynchronous<br />

execution means that immediately after the <strong>Mobile</strong> App calls the method, it continues<br />

to execute the next JavaScript statement or to evaluate the next term of an expression.<br />

Results of an asynchronous method execution only become available to the <strong>Mobile</strong><br />

App when an event associated with the method fires and an event handler function that<br />

is subscribed to the event executes and receives the results.<br />

98 <strong>OpenEdge</strong> ® <strong>Development</strong>: <strong>Mobile</strong> <strong>Applications</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!