
The add-on program for all major browsers.
Google Gears is a kind of bridge between offline and online, since one of the main functions provided to the user (in this case, the developers of various web services) is the ability of the application to work without connecting to the Internet, while maintaining all the functionality and features, and after connecting - synchronize the status with the server. But this, of course, is not all - the built-in database and local web server can do much more, especially in the capable hands of developers.
Previously, I already wrote about the different APIs that can be implemented in Gears, and now let's see what is in the new version.
Major changes:
- HttpRequest is a complete implementation of the W3C XmlHTTPRequest object , which is now available both for the main page (that is, as one of the objects created through the Gears API) and inside workers. Precisely because of this, this module, in fact, was conceived. Gears provides an opportunity to simulate multi-threaded execution of various JavaScript calculations by distributing them to the so-called Workers, individual processes (combined in the Worker Pool ), which assume the background execution of the specified code. Inside this process, the code is isolated and previously could not communicate with the outside world in any way, except through the worker's interface. Now, from such a code, you can call and work with remote sites, and this opens up great prospects for web developers.
- Timer - the flaws of the built-in timer in JS have long been known (in general, there is only one - non-guaranteed accuracy of timing, and the smaller they are, the more spread there may be). Now, Gears has its own timer implementation, based on the HTML 5 specification , which already has a familiar interface, so if your code is oriented to the standard timer, almost nothing needs to be redone. Yes, of course, the timer is available both in the global application (on the page) and in the code inside the workers.
- Improved error handling within code executed by worker. Previously, such code was difficult, if not impossible to debug in real conditions (that is, when it is executed by Gears), now these errors are transmitted above to the main page and there can be intercepted by means of debugging JavaScript code, for example, Firebug. Also, an error handler appeared in the WorkerPoll API, which allows you to independently detect and respond to errors.
- Creating a worker by specifying a script URL . This is a new and long-awaited opportunity, as the developers say - now there is no need to manually download and transfer the necessary code to the workers - you select the code that should be executed separately, in a separate JS file, and then simply create the Worker and specify the URL of this script, shifting all work on loading and executing code on gears.
These are the innovations. Of course, this is not as revolutionary as many would like, and there is still a lot of some functionality left unrealized, only in projects. Now the developers of Gears are evolutionarily improving their development, gradually improving and adding new features to already existing components, not hurrying to add completely new functionality. New features, albeit simple, but allow you to implement much more advanced and functionally rich solutions than before. The very concept of WorkerPoll is very useful and allows you to shift some of the complex calculations performed on the client onto the shoulders of the application, thus unloading the browser and providing the best performance of rich interfaces of modern web applications. By the way, this way you can significantly speed up (this is just a guess) for the application, bypassing the restrictions on the number of simultaneous connections to a single domain. And the timer finally allows you to implement accurate readings of small time intervals, regardless of the system timer (especially if you need to use multiple timers or complex calculations at the same time).
Download Google Gears here , there are links to the portal for developers and other materials.
')
PS This is a cross-post from my personal blog , I thought it would be interesting for the habra people.