Re: [whatwg] Storage Events for a Specific Storage Area

2009-07-13 Thread Ian Hickson
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.   `._.-(,_..'--(,_..'`-.;.'


Re: [whatwg] Storage Events for a Specific Storage Area

2009-07-13 Thread Joseph Pecoraro
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.


Sounds great.  Although wouldn't now be the best time to introduce  
something new?  Its not a breaking change (theoretically), its an  
additional feature.  Its my understanding that most of Web Storage is  
undergoing changes (B-trees and SQL orthogonally), but the Storage  
interface is not going to change much?  Is that because of current  
browser support?



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


Fair enough. =)



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


We're all learning. =P


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


- Joe

Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-24 Thread Joseph Pecoraro
This doesn't break anything in the current spec.  So it wouldn't  
break

any existing implementations.  I'm also guessing that the groundwork
for implementing a feature like this is already in place due to the
ubiquity of addEventListener.


To be frank, it seems like a lot of bloat though to avoid a simple  
comparison.


Its my thinking that the simple comparison shouldn't be necessary to  
begin with.  Thats why I suggested this.


This is a probably a bad analogy, but would it make sense to put a  
click function on just the window object and check every time it  
fires to see if it fired in the div you were interested in?  Imagine  
every single click listener you register fires every time you click  
on something... that doesn't scale.  (The reason this is a bad is  
because these click events bubble.  Maybe bubbling is appropriate  
here)?



- Less Listener Functions Fired - Instead of every registered  
listener

getting fired on every storage event, only those applicable will be
fired.  This may mean overall less listeners getting fired, and code
that doesn't have to continually check the affected storageArea,
leading to potential performance improvements.


Actually, assuming only one of the two solutions would exist the  
same amount of events would fire. A change to localStorage causes an  
event to be dispatched and likewise a change to sessionStorage  
causes an event to be dispatched. Having said that, with your  
solutions more events will fire since the legacy event will have to  
be dispatched too.


What do you mean when you say more events will fire?  Why not just  
fire the same storage event but now put the if statement that the  
web developer had to always write and put it into the browser's  
dispatching code.  This may be my inexperience with the  
implementations, but I honestly don't see how this could end up firing  
more events.


I think looking at it this way (more events) is looking at it  
sideways and maybe a bit pessimistically.  If my first thought is  
this is going to be really complex then my next thought is how can  
I simplify this and if I can't find a way to simplify it I would  
state why it can't or shouldn't be done.  I don't see that here, I  
just see the this is really complex part.  I'm guessing that there  
is a simpler way to look at this, and if not I'd be interested to know  
why this seems so complex.



- Joe



Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-23 Thread Anne van Kesteren
On Mon, 22 Jun 2009 18:45:34 +0200, Jeremy Orlow jor...@chromium.org wrote:
 Seems like a reasonable idea.  I don't know if it's been brought up  
 before. My guess is that Ian will say this should be re-examined for HTML6,  
 though.

Seems like that would be a bit too late; given existing deployment I don't 
expect changes to this to be within the realm of possibilities.

By the way, change requests for this specification should be made to 
public-weba...@w3.org. localStorage and friends are no longer part of HTML5.


-- 
Anne van Kesteren
http://annevankesteren.nl/


Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-23 Thread Jeremy Orlow
Is it too late?  It seems as though Joseph's suggestion could be in addition
to what's already in the spec.

On Tue, Jun 23, 2009 at 2:54 AM, Anne van Kesteren ann...@opera.com wrote:

 On Mon, 22 Jun 2009 18:45:34 +0200, Jeremy Orlow jor...@chromium.org
 wrote:
  Seems like a reasonable idea.  I don't know if it's been brought up
  before. My guess is that Ian will say this should be re-examined for
 HTML6,
  though.

 Seems like that would be a bit too late; given existing deployment I don't
 expect changes to this to be within the realm of possibilities.

 By the way, change requests for this specification should be made to
 public-weba...@w3.org. localStorage and friends are no longer part of
 HTML5.


 --
 Anne van Kesteren
 http://annevankesteren.nl/



Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-23 Thread Joseph Pecoraro
Jeremy Orlow: Is it too late?  It seems as though Joseph's  
suggestion could be in addition to what's already in the spec.


This doesn't break anything in the current spec.  So it wouldn't break  
any existing implementations.  I'm also guessing that the groundwork  
for implementing a feature like this is already in place due to the  
ubiquity of addEventListener.


Pros:

- Less Developer Confusion: When a web developer is focusing on a  
particular Storage area and set a storage listener, unless they  
check the storageArea they may not realize their listener is getting  
fired for scripts dealing with a different Storage area.  I'm not sure  
if this can be considered a security threat but it would certainly  
limit the potential for problems.
- Less Listener Functions Fired - Instead of every registered listener  
getting fired on every storage event, only those applicable will be  
fired.  This may mean overall less listeners getting fired, and code  
that doesn't have to continually check the affected storageArea,  
leading to potential performance improvements.


Cons:

- This is similar to implementing the full EventTarget Interface on  
Storage areas.  However, the only event of importance on a Storage  
area is storage not click or hover etc.  Invalid event types  
should probably throw an error or something... or maybe this is more  
in the scope of DOM Events.



Anne: By the way, change requests for this specification should be  
made to public-weba...@w3.org. localStorage and friends are no  
longer part of HTML5.


I read from your (Anne's) blog that Web Storage has split off of  
HTML5, and I see it on the WebApps homepage [1] but the document  
itself said to send feedback to either mailing list or the bugzilla  
[2].  I just subscribed.  In the future I'll use the other list for  
whats on the WebApps homepage.


[1]: http://www.w3.org/2008/webapps/charter/
[2]: http://dev.w3.org/html5/webstorage/#status-of-this-document


- Joe

Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-23 Thread Anne van Kesteren
On Tue, 23 Jun 2009 19:51:18 +0200, Joseph Pecoraro joepec...@gmail.com wrote:
 Jeremy Orlow: Is it too late?  It seems as though Joseph's
 suggestion could be in addition to what's already in the spec.

 This doesn't break anything in the current spec.  So it wouldn't break
 any existing implementations.  I'm also guessing that the groundwork
 for implementing a feature like this is already in place due to the
 ubiquity of addEventListener.

To be frank, it seems like a lot of bloat though to avoid a simple comparison.


 - Less Listener Functions Fired - Instead of every registered listener
 getting fired on every storage event, only those applicable will be
 fired.  This may mean overall less listeners getting fired, and code
 that doesn't have to continually check the affected storageArea,
 leading to potential performance improvements.

Actually, assuming only one of the two solutions would exist the same amount of 
events would fire. A change to localStorage causes an event to be dispatched 
and likewise a change to sessionStorage causes an event to be dispatched. 
Having said that, with your solutions more events will fire since the legacy 
event will have to be dispatched too.


 Cons:

 - This is similar to implementing the full EventTarget Interface on
 Storage areas.  However, the only event of importance on a Storage
 area is storage not click or hover etc.  Invalid event types
 should probably throw an error or something... or maybe this is more
 in the scope of DOM Events.

That is still quite a bit of complexity for little benefit.


-- 
Anne van Kesteren
http://annevankesteren.nl/


Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-22 Thread Jeremy Orlow
Seems like a reasonable idea.  I don't know if it's been brought up before.
My guess is that Ian will say this should be re-examined for HTML6, though.

J

On Fri, Jun 19, 2009 at 9:07 PM, Joseph Pecoraro joepec...@gmail.comwrote:

 It sounds like there wasn't any discussion on this.  I recently heard talk
 of other potential Storage areas [2]. That would make this idea even more
 appealing to me.  Does this sound like something worth adding?  Any
 comments?

 [2]:
 http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-June/020485.html


 On Jun 17, 2009, at 1: 44PM, 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?

 Cheers,
 Joe

 [1]: http://dev.w3.org/html5/webstorage/#the-storage-event





Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-22 Thread Joseph Pecoraro
Seems like a reasonable idea.  I don't know if it's been brought up  
before.  My guess is that Ian will say this should be re-examined  
for HTML6, though.



Very cool.  Let me know if I can help at all to push this idea forward.

- Joe


Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-22 Thread Alexandre Morgaut
I'd find these events useful and consistent too

All the more when you want to listen events on storage happening very 
occasionally without the charge of listening other storage events happening 
very often...
You might have some significant performance differences


-Message d'origine-
De : whatwg-boun...@lists.whatwg.org [mailto:whatwg-boun...@lists.whatwg.org] 
De la part de Joseph Pecoraro
Envoyé : lundi 22 juin 2009 18:56
À : Jeremy Orlow
Cc : whatwg@lists.whatwg.org
Objet : Re: [whatwg] Storage Events for a Specific Storage Area

 Seems like a reasonable idea.  I don't know if it's been brought up  
 before.  My guess is that Ian will say this should be re-examined  
 for HTML6, though.


Very cool.  Let me know if I can help at all to push this idea forward.

- Joe


Re: [whatwg] Storage Events for a Specific Storage Area

2009-06-19 Thread Joseph Pecoraro
It sounds like there wasn't any discussion on this.  I recently heard  
talk of other potential Storage areas [2]. That would make this idea  
even more appealing to me.  Does this sound like something worth  
adding?  Any comments?


[2]: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-June/020485.html

On Jun 17, 2009, at 1: 44PM, 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?


Cheers,
Joe

[1]: http://dev.w3.org/html5/webstorage/#the-storage-event