Use Ionic plugin in web working

How can I use Ionic Plugin in Web Worker? Particularly org.apache.cordova.contacts

if it helps.

Inspired by “ Can Angular be run on a web worker? ” I'm trying to do:

self.window = self;
self.window.Event = function() {};
self.window.innerHeight = 1;
self.history = {};
self.document = {
  readyState: 'complete',
  addEventListener: function() {},
  querySelector: function() {},
  getElementsByTagName: function() {
    return [];
  },
  createElement: function() {
    return {
      pathname: '',
      setAttribute: function() {}
    };
  },
  createEvent: function() {
    return {
      initEvent: function() {}
    };
  },
 documentElement: {
    style: {
      transition: ''
    }
  },
  head: {
    children: [],
    appendChild: function(child) {
      importScripts('../../' + child.src);
      child.onload();
    }
  },
  body: {
    classList: {
      add: function() {},
    }
  },
};

importScripts('../../lib.js');
importScripts('../../cordova.js');

      

This loads it, but navigator.contacts.find

is undefined after running. :(

Is there an easier way? My ultimate goal is to connect phone contacts asynchronously.

(I need to do this because it navigator.contacts.find()

is a blocking call and it takes about 1 minute to load the entire contact list).

+3
angularjs cordova web-worker ionic


source to share


No one has answered this question yet

See similar questions:

4
Can Angular run by a webmaster?

or similar:

277
Web workers without a separate Javascript file?
133
What are the use cases for web workers?
85
Chrome cannot load web user
66
AngularJS and web workers
45
Passing objects to a web worker
2
Will web workers be helpful for an ionic app?
1
Accessing the web worker plugin
1
Ionic cord plugins not defined
1
How to connect to SQLite database in Web Worker on Cordova / Ionic platform?
0
ionic / cordova plugin not compiled



All Articles
Loading...
X
Show
Funny
Dev
Pics