Friday, March 21, 2008

Joose on Gears

You can now automatically execute methods of a Joose.Class in a different thread using Google Gears. All you need to do is use the meta class Joose.Gears and add a worker method. All the Gears-Interfacing is handled for you. If Gears is not present, the worker is executed in the main thread. The workers result will be sent to a method called "on".ucfirst($worker_name) if available:

Class("HardWork", {
meta: Joose.Gears,
has: {
data: {is: rw, init: {}}
methods: {
onDoWork: function (result) {
ok(result == 1001, "Gear Worker returns correct result")
workers: {
doWork: function (start) {
var counter = start;
for(var i = 0; i < 1000; i++) {
return counter

var hw = new HardWork();

Post a Comment