tangrams/tangram — pull request #49 by bcamper (2014-10-27 02:30:28+00:00)
Title: Worker broker: enable callback-style calls from main thread to web workers

Adds a ```WorkerBroker``` object that facilitates more traditional JS async callback-style code when communicating with web workers.

The main thread can send a message to a worker. The provided message ```type``` invokes a method of the same name within the worker, and the return value is sent from the worker back to the main thread, where it is passed along to a callback (optionally).

This helps with execution flow clarity, since previously when a worker needed to send a result back to the main thread, the relationship of calls between the two threads was not obvious or documented in one place. With the broker, these calls can be written in the same style as any other callback-based code would.

The eventual goal here is to use the ES7 ```async/await``` pattern to allow synchronous-style code in the main thread to temporarily suspend while the worker executes.