Home

# Class goog.gears.Worker

This is an absctraction of workers that can be used with Gears WorkerPool.

extends goog.events.EventTarget

Instance Method Summary

`disposeInternal()`

Unattach listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners, it should be something like this:

    MyClass.prototype.disposeInternal = function() {
    MyClass.superClass_.disposeInternal.call(this);
    // Dispose logic for MyClass
    };

| `getId() ⇒ number` Gets an ID that uniquely identifies this worker. The ID is unique among all worker from the same WorkerPool.
| `handleMessage(?GearsMessageObject messageObject)` Called when we receive a message from this worker. The message will first be dispatched as a WorkerEvent with type {@code EventType.MESSAGE} and then a {@code EventType.COMMAND}. An EventTarget may call {@code WorkerEvent.preventDefault()} to stop further dispatches.
| `init(number id)` Initializes the worker object with a worker id.
| `sendCommand(number commandId, ?Object params)` Sends a command to the worker.
| `sendMessage(<Any Type> message)` Sends a message to the worker.

Static Method Summary
| `isCommandLike(<Any Type> obj) ⇒ boolean` Whether an object looks like a command. A command is an array with length 2 where the first element is a number.