[whatwg] Storage Events for a Specific Storage Area

Ian Hickson ian at hixie.ch
Mon Jul 13 03:10:52 PDT 2009


On Wed, 17 Jun 2009, Joseph Pecoraro wrote:
>
> The "storage" event [1] fires for both sessionStorage and localStorage.  
> To me, this means if you only want to interact with localStorage you 
> will have to manually ensure that it is the storage area being modified:
> 
>   window.addEventListener('storage', function(e) {
>     if ( e.storageArea === localStorage ) {
>       // ...
>     }
>   }
> 
> Was there any discussion about creating events specific to the storage 
> object, or should that already be possible?  I've been playing around 
> with WebKit's Storage implementation, and the following (understandably) 
> is not possible:
> 
>   > localStorage.addEventListener
>   undefined
> 
> Is there any way to listen to events for a single specific storage area 
> or is the previously mentioned approach preferred?

We could make Storage into an EventTarget and also fire events on there, 
sure. As Jeremy said, this is something that might best be done in the 
next version; we're still trying to get the current features implemented 
in a stable and consistent fashion as it is.

In general, though, I don't think it's critical, since you can easily work 
around it by checking which was changed based on the event data.

(I agree that your proposal would have made more sense. I'm sorry my 
learning experiences have such a detrimental effect on the Web! :-) )

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list