-
Notifications
You must be signed in to change notification settings - Fork 113
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
Observable available in store2? #71
Comments
If you are talking about multiple user-interfaces communicating with each other, you first need to clarify whether these Vue/React/Vanilla webapps are open in the same browser window or tab or different ones. If they are open in the same, then no, i don't have any support for watching changes because store() uses localStorage which is a browser native object. I doubt it is even possible to observe that like you would a normal object. If you are talking about webapps open in different windows or tabs, then i do have support for that via an extension called store.on.js. This is possible because browsers provide an event listener hook to tell when a different window has made a change to the localStorage. It does not fire events for changes within the same window, though. As for returning Promises, you first need to understand that localStorage is purely synchronous. You do not need to wait for Promise resolution. When you make any call to store(), it is executed synchronously. No promise necessary. You can be sure your update is successful as long as no quota error was thrown. If, however, you are working with an API that requires you to speak in Promises, there is an extension called store.async.js that may prove convenient. This uses setTimeout to wrap your store() call execution to force it to be asynchronous. In my opinion, it has no serious use, but if you really want it, it is there. |
Hi nbubna, Many thanks for your feedback. 👍 Ok ... then I think we have to solve our problem by another way. But if you say all is syncronous then the following code should be work correct ... right?
When YES, then I have another problem in my logic. :) Mario |
Yes, all localStorage operations (and sessionStorage) are purely synchronous, so store() is also. Now that i have someone with an actual use case for detecting store() changes in the same window, i may take some free time to see if i can't create a solution for detecting those changes as well. You should not wait on that, though, as it is a busy time for me and it would be an experiment. I do wish the browsers would fire storage events for localStorage changes in the same window, but they do not. :( |
No Problem. Take your time. :) Wish you luck, :) Thank you and best regards, |
Hi,
Sorry for my bad englisch before ... :)
Currently we evaluate whether we could use store2 in our projects.
For better understanding our requirements:
The pages in our applications are based on multiple web-apps based on Vue.js, React or Vanilla, etc ... at same time.
We need a store for our application states.
My question is:
Is there a functionallity in your library to use "Observables" that any applications will triggert automatically by changes where variables from the store are used?
[EDIT]
Another improvement will be to have promises that I can sure that my value is updatet successful in my store like this:
... same fpr set() or setAll() ...
If I am blind or do not understand your documentation then "sorry" so far. :)
Best regards,
Mario
The text was updated successfully, but these errors were encountered: