Re: localStorage Event

On 1/28/10 11:57 PM, Jared Morse wrote:
> Even though it occurs on the same document, doesn't mean loosely coupled
> code can't benefit from it.
>
> Imagine if each time you added a feature to a web app that depended on
> knowing a current value from the storage, you'd have to go around to all
> the places that value is changed and add some code to alert your new
> code.  If storage events triggered on the same document, all you would
> have to do is set a listener.

If you really need this behavior, you can always dispatch your own event
to the window when you change the data.


-Olli


>
> -J
>
> On Thu, Jan 28, 2010 at 1:41 PM, Olli Pettay <Olli.Pettay@helsinki.fi
> <mailto:Olli.Pettay@helsinki.fi>> wrote:
>
>     On 1/28/10 9:34 PM, Jared Morse wrote:
>
>         Hi, I have a concern about the web storage event spec
>         (http://dev.w3.org/html5/webstorage/).
>
>         The spec states:
>         "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 something, then in every HTMLDocument object whose
>         Window
>         object's localStorage attribute's Storage object is associated
>         with the
>         same storage area, other than x, a storage event must be fired..."
>
>         My concern lies with the "other than x" part.  Unless I'm missing
>         something, these events would be even more useful if they also
>         fired in
>         the HTMLDocument that initially made the storage call.
>
>
>     The page which is changing storage object knows already that the
>     storage object is being changed. Why would it need explicit
>     notification (event) about that?
>
>
>     -Olli
>
>
>
>
>
>         Thanks for your time.
>
>         -Jared
>
>
>

Received on Thursday, 28 January 2010 22:07:09 UTC