+

Search Tips | Advanced Search

For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


JSONStore concurrency

Learn about JSONStore concurrency.


JavaScript

Most of the operations that can be performed on a collection, such as add and find, are asynchronous. These operations return a jQuery promise that is resolved when the operation completes successfully and rejected when a failure occurs. These promises are similar to success and failure callbacks.

A jQuery Deferred is a promise that can be resolved or rejected. The following examples are not specific to JSONStore, but are intended to help you understand their usage in general.

The Options Object with onSuccess and onFailure callbacks that were used in JSONStore for IBM® Worklight® V5.0.5 are deprecated in favor of promises.

Instead of promises and callbacks, we can also listen to JSONStore success ('WL/JSONSTORE/SUCCESS') and failure ('WL/JSONSTORE/FAILURE' events. Perform actions that are based on the arguments that are passed to the event listener.


Objective-C

When we use the Native iOS API for JSONStore, all operations are added to a synchronous dispatch queue. This behavior ensures that operations that touch the store are executed in order on a thread that is not the main thread. For more information, see the Apple documentation at Grand Central Dispatch (GCD).


Java™

When we use the Native Android API for JSONStore, all operations are executed on the main thread. You must create threads or use thread pools to have asynchronous behavior. All store operations are thread-safe.

Parent topic: JSONStore advanced topics