Titanium Connector

Categories

Component ID

2293373

Component name

Titanium Connector

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

This is a hack. Titanium does not handle Ti.App.fireEvent from remotely-loaded html. This hack implements a message queue that can be polled from Titanium to communicate messages.

Here is an example snippet that will do the polling from Titanium:

setInterval(function(){
  var tiQueue = $.webview.evalJS("pollTiQueue();");
  if (!tiQueue) return;
  tiQueue = JSON.parse(tiQueue);
  if (tiQueue.length > 0) {
    processQueue(tiQueue);
  }
}, 100);


function processQueue(tiQueue) {
  for (var i=0, l=tiQueue.length; i<l; i++) {
    processQueueItem(tiQueue[i]);
  }
}
function processQueueItem(item) {
  switch (item.type) {

    case "DOM_READY":
      webviewReadyDef.resolve();
      break;
  }
}