Skip to content

Conversation

@alvinlindstam
Copy link

We needed to be updated when another window changed a value, so this PR implements forwarding storage events from the hub to the client.

Resolves initial request in #19. It tries to behave like the storage event as much as possible, rather than implementing own event for different types of requests. This also means that no events will be sent from hubs that actually make the changes.

Feedback appreciated, I'm not sure if I've followed all conventions of the library or if the API is the best available.

@alvinlindstam
Copy link
Author

Looking at the travis log, it seems that there is some credential issue preventing the tests from running rather than test failures in this branch.

@danielstjules
Copy link
Contributor

Thanks again! Will try to look at the PR this week :)

@alvinlindstam
Copy link
Author

Have you had a chance to look at this, @danielstjules?

@JasonLi914
Copy link

JasonLi914 commented Jan 4, 2017

I would also like to see this or a similar feature if possible. Thank you for your time!

@danielstjules
Copy link
Contributor

Unlike localStorage events, it looks like these would fire to all clients, including the source of the change

https://html.spec.whatwg.org/multipage/webstorage.html#the-localstorage-attribute

When the setItem(), removeItem(), and clear() methods are called on a Storage object x that is associated with a local storage area, if the methods did not throw an exception or "do nothing" as defined above, then for every Document object whose Window object's localStorage attribute's Storage object is associated with the same storage area, other than x, send a storage notification.

@alvinlindstam
Copy link
Author

@danielstjules: The Hub uses the localStorage event, so the client that initiates the change will not get an event since the hub does not. Also, if multiple clients somehow use the same hub window, they won't get any updates when the other clients update the data.

@danielstjules
Copy link
Contributor

Since this was a pretty old PR, I didn't want to bother you with changes. I've squashed it and am taking it over in another branch. Thank you so much! :)

@danielstjules danielstjules mentioned this pull request Jun 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants