-
-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML5 web worker support? #76
Comments
Hi! I have not tested it from a web worker but I understand that it would be important use case. Having that said, I believe there are good chances that Dexie would work in a web worker if including it as requirejs module. It is written to adapt to both window- and non-window environments by using "this" instead of window for global scope and all external dependencies are picked from a local "window" variable that actually is initiated from "this" at global scope, which in a web worker would be DedicatedWorkerGlobalScope. Therefore I hereby ask the community to test that out and report back on this issue whether Dexie is supported from a web worker environment or not. If not, I will be helpful correcting what is needed to be corrected to make it work. |
Hi David, |
Thanks for testing! Suppose you were using dist/latest/Dexie.js. If so, it seems that we'd have to change the way it detects non-window environments. |
I am creating a unit test for it now and I got the same error. Solution hopefully on its way... |
Unit tested and solved issue#76. Dexie can now be used from within a Web Worker. Unit test runs successfully in IE11, Chrome and Opera but fails in Firefox 36. Should be supported in Firefox 37 according to the following Mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=701634 .
Solution checked in. Please try it using src/Dexie.js because it is not yet released to dist. |
Hi David, |
Are you sure? My unit test did not use requrejs. I just did importScripts("src/Dexie.js") in the worker and then I could start using it |
Sorry. I think it was my mistake. I was using dexie in setInterval function and the first was empty I did not wait until the second interval. It was fine from the second interval. Many thanks. |
Addons Dexie.Syncable and Dexie.Observable made compliant with WebWorkers also. Made it possible to test that in the unit test suite when including the addons.
Ever since commit 722aa20 that resolved #76 (Web Worker support), the code completion when using Dexie in Visual Studio has been broken. The reason was that 'window' was replaced with 'self' to support WebWorker environment. But self is not handled by VS intellisense engine. To work around this, 'self' is replaced with 'self || window' and the nice intellicense came back to live...
Hi there. I would like to know if this wrapper works inside the web worker? If not, adding this feature would greatly be helpful. Thank you.
The text was updated successfully, but these errors were encountered: