-
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
Make localForage observable #244
Comments
Would something like #104 do the trick? Or do you mean using |
I don't know if this would be sufficiant. There are no events for indexeddb and websql. I'm developing a browser extension. Within the content script I record user interactions and send them to the backend script to store the data into the extensions "storage". I also do have a popup UI to modify the recorded data. I would love to add observers from popup and content script react on changes to the storage. If a user changes something within the popup it should be possible to see the updates without a reload of the content script or a periodic query. |
would this event handler work? https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase.onversionchange I'm not sure if this fires across tabs/windows though. |
@mreinstein I think the idea would be to have it be observable for all events, so you could know when a localForage object fired any event ( |
I think we're saying the same thing. I surfaced the |
I think As @inf3rno noted on #104, probably From the OP:
The particular case where one window is a popup can be solved with postMessage to the parent window. It's harder (impossible?) when the user opens two unrelated windows on the same domain. The only hack I can think of would be if each window periodically does an explicit |
Hello, Is there any solution to this currently? I would like to use this with angular2 and observable it would be great if this app could support observable. Thanks. |
Would a simple publish-subscribe implementation suffice for this? Of course Any suggestions on the API? Eg: Perhaps we could have two separate methods for localforage-method or
|
This is actually something that's not technically feasible right now, at least with IndexedDB and WebSQL. It does work with LocalStorage, so as a hacky workaround you can actually just toggle a key on LocalStorage whenever something changes, and then LocalStorage emits an event, which means you can also communicate across tab boundaries this way. OTOH you may want to wait, because they're actually in the process of adding event listeners to the IDB spec. There's a draft proposal somewhere, but I can't seem to find the link now, but @drufball would know where to find it. |
How about initially making localforage instances observable, so that parts could also support listening for db changes from different page instances.Thodoris Greasidis |
Hi, Thanks that would be great. I hope browser will implement this soon. |
Any preference on any Observable library to use? I guess vanilla js folks
|
Just pushed some commits to my localForage-observable repo. By default it for your feedback.Thodoris Greasidis |
Hi, |
@thgreasi Does this work for multiple tabs or windows or is this limited to a single instance? |
@maysale01 no, it doesn't work across tabs, only on the same instance. Like @nolanlawson said a few comments before, it isn't technically possible atm. I may add his hacky localStorage suggestion in some later release though. |
Cross-tab observation might be a thing if we can implement/agree upon/release this: |
Just opened localForage/localForage-observable#5 to track the cross-tab support. |
The plugin allows using observable, please follow localForage/localForage-observable#5 for cross-tab support 😄 |
Just opened localForage/localForage-observable#6 for this. Any feedback would be great and could help releasing it during the weekend. |
Correct me if I'm wrong but I dont see any convenient way to register callbacks to localForage which are executed when a storage changed.
Are there any plans to provide/merge such a feature?
The text was updated successfully, but these errors were encountered: