-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
use localforage in a serviceworker #402
Comments
It is a design goal of localforage to work in web workers. You're right though ; it currently doesn't work. If you can send a pull request that fixes it that would be great, but if not know it's something I'll eventually work on :-)
On Wed, Jul 15, 2015 at 10:06 AM, Remko Boschker [email protected]
|
replacing .call(window) by .call(this) loads the lib just fine, but this probably introduces other issues. I'll fork and run some tests later today. Thanks. |
Awesome, thanks so much. If you run the tests using
On Wed, Jul 15, 2015 at 10:27 AM, Remko Boschker [email protected]
|
.call(typeof window !== 'undefined' ? window : this) On Wed, Jul 15, 2015, 12:31 Matthew Riley MacPherson <
|
😄 sure, will use it. |
This might be useful. |
Just took a shot on this, the web workers part, at least... Hope it will On Wed, Jul 15, 2015, 14:57 Remko Boschker [email protected] wrote:
|
In the service worker your fix raises
Also a unit test fails
I'll work on a fix |
We might just have to use a different var name for the scope. Maybe service On Mon, Jul 20, 2015, 11:37 Remko Boschker [email protected] wrote:
|
Can you share your service worker test code? On Mon, Jul 20, 2015, 13:29 Thodoris Greasidis [email protected] wrote:
|
Hi, I mistakenly took the src instead of the build with the drivers in the file. Sorry for that. I noticed that window has a property |
Yes, I had that in mind, but wanted to avoid possible problems with the On Tue, Jul 21, 2015, 17:25 Remko Boschker [email protected] wrote:
|
Let me rephrase that, since I think I might missed my point/wasn't clear:
Still, I have no problem using just |
@thgreasi I do not mind the extra precaution. Can you confirm that the test are passing in your localforage#webworkers-fix? I tried to copy the webworkers test to a serviceworker scenario but the tests are not passing. When I include only the test.webworker.js in the test.component.html not a single test is run. |
I believe the webworker tests are commented out right now, or more accurately are marked as Let me know if it seems like that's the case but you need more help. — On Thu, Jul 23, 2015 at 10:12 AM, Remko Boschker [email protected]
|
@tofumatt, @remkoboschker @remkoboschker I also started looking at a service worker test case (today morning), but it is still in embryonic state I think. |
@thgreasi I have a basic unit test
test.serviceworker.js:
It runs in a browser, but not in Phantomjs; don't know why |
That looks very similar to my code! On top of that, I'm currently trying to On Thu, Jul 23, 2015, 14:57 Remko Boschker [email protected] wrote:
|
Can I find this code in any public commit that I can cherry pick and push On Thu, Jul 23, 2015, 16:55 Thodoris Greasidis [email protected] wrote:
|
I have pushed the branch to https://github.com/curit/localForage. In test/test.serviceworker.js en in test/serviceworker-client.js an earlier attempt to send messages is commented out. I found this example to be quite useful https://jakearchibald.github.io/isserviceworkerready/demos/postMessage/ Good luck! |
Is there any chance you can rebase over the latest commit of my PR (and On Thu, Jul 23, 2015, 17:49 Remko Boschker [email protected] wrote:
|
@thgreasi sorry about the diff I was trying to get the unit test to run at all. I'm working on it. By the way how do I get at the pull request in git or should I fork your repo? |
Turns out the component-build was not being executed. So now I can run the tests and have submitted a pull request to your repo. I will now try to get the tests to pass. I found this useful to fetch the pull request https://help.github.com/articles/checking-out-pull-requests-locally/ |
thgreasi#1 now has both tests passing when run in Chrome 44 |
and in firefox nightly with the dom.serviceworker enabled |
It does not look like phantomjs supports serviceworkers. I have asked some questions jakearchibald/isserviceworkerready#43 and ariya/phantomjs#13437 |
Just 1 thing to note: awesome 👍 |
@thgreasi Thank you. I'm away on holiday the coming weeks. So good luck with the pull request! |
@remkoboschker best wishes regarding your holidays. I will try to finish this up by the time you are back. |
@remkoboschker Awesome work!!! I'm speechless 😮 😮 😮 😃 |
Hi,
I would like to use localforage in a serviceworker. Version 1.2.4 in Chrome 43 throws a reference error on line 963 "window undefined", because there is no window in the serviceworker.
Window was removed in #144 but reintroduced in #237.
Should localforage or should it not be usable in a webworker / serviceworker environment?
I'll see if I can get it to work.
The text was updated successfully, but these errors were encountered: