function workerFn() {
    var _this = this;

    var interval = void 0;
    this.onmessage = function (e) {
        switch (e.data) {
            case true:
                if (!interval) {
                    interval = setInterval(function () {
                        _this.postMessage(true);
                    }, 1000 / 30);
                }
                break;
            case false:
                if (interval) {
                    clearInterval(interval);
                    interval = 0;
                }
                break;
            default:
                _this.postMessage(e.data);
                break;
        }
    };
}
WebWorker background function.

When we're in the background this will send us a msg every tick, when in
the foreground it won't.

When running in the background the browser reduces allowed CPU etc, so
we raun at 30fps instead of 60fps.