evaluateJavaScript

Evaluates the given js code and delivers the outcome to completion as a TealiumResult wrapping a DataItem.

A successful result contains the value returned by the script. A failure result indicates that an error occurred during evaluation.

Threading: this method is called on the Tealium thread, and the caller disposes the returned Disposable on the Tealium thread. completion must be called on the Tealium thread (see TealiumContext.schedulers); it may be called synchronously, before this method returns.

Completion: call completion exactly once, unless the caller has disposed the returned Disposable.

Cancellation: the caller may dispose the returned Disposable to cancel the evaluation. After that, calling completion is not required, and the caller ignores any call. Disposing after completion has been called must have no effect. Implementations with nothing to cancel, including synchronous ones, return Disposables.disposed.

Return

A Disposable that cancels the in-progress evaluation, or Disposables.disposed if there is nothing to cancel.

Parameters

js

The JavaScript code to evaluate.

completion

The Callback to call, via Callback.onComplete, with the outcome, as described above.