I'm doing a mobile app with phonegap. My app communicate with a server in order to have the content of the page. What I want to do, is not load the content of each page thanks to the versionning. I change the content of the pages on my app only if the content in the server has change. In order to check if the content change, I would like to run a thread in background in order to see if there is new content or not. This is why, I would like to know if it's possible to do multithreading with phonegap? I know that it's possible with HTML5, so it must be possible with phonegap (ps : I don't want to use plugin for each platform if it's possible). Thanks.
Asked
Active
Viewed 4,643 times
1 Answers
0
You can do multithreading in JavaScript with Web Workers, but unfortunately you are limited on what you can do with it and it is not supported entirely across all platforms.
If all you are wanting to do is make a server call in the background and web workers are supported on the platform you are targeting, then that's the way I would go.
Edit: As of 2016 you can use Web Workers across all platforms except for miniOpera. This means that it will work in Cordova/Phonegap. It is true that Web Workers cannot touch DOM objects or the Document, Parent, or Window objects. Luckily, you can touch these objects in your onmessage handler.
Overall, this is a great way to handle background data-management.

Community
- 1
- 1

Andrew Lively
- 2,145
- 2
- 20
- 27
-
Are you sure? because recently I find the roadmap of cordova says that It will not be here before this summer : http://wiki.apache.org/cordova/RoadmapProjects. – user2429082 Apr 27 '14 at 09:52
-
We have an app in the App Store currently that uses Web Workers, but because of the lack of support on Android we have not implemented it there. I'm not exactly sure what they are looking to do when they mention it on their roadmap, maybe provide more official support and documentation. Just make sure to check if the platform version you are developing for [is supported](http://caniuse.com/#search=web%20workers). – Andrew Lively Apr 28 '14 at 12:24