Re: [cssom-view] addMediumListener / removeMediumListener

On Sun, 04 Jul 2010 18:30:10 +0200, Kenneth Christiansen  
<kenneth.christiansen@openbossa.org> wrote:
>> 2010/5/31 Anne van Kesteren <annevk@opera.com>
>>> Given those I guess we should go with matchMedia / addMediaListener /
>>> removeMediaListener to match @media and media="" which both also accept
>>> media query lists.
>>
>> I prefer Media instead of Medium as well.
>
> Could we agree on this then? Anne?

I think we have, yes. Though only if Simon or Dean agrees as well.  
matchMedium already changed once and I'd like explicitly buy-in before  
doing it again.


>>> Does that give a convenient API though? You would need to keep some  
>>> table around with the mapping from token to media query list.
>>
>> To be able to use the context information in the callbacks it is needed  
>> to store it somehow anyway. The query may be stored in its canonical  
>> form or it may be stored in its original form and converted every time  
>> a callback is received. As the query serialization may be quite  
>> expensive that later
>> option may be not that good.
>> I think that to return a token to be used later to identify the  
>> callback is ok.
>
> Sounds sensible to me.
>
>> We could make addMediaListener return the serialized media query. It  
>> could then be used in the callbacks as a token, without considering its  
>> contents, or as the media query if wanted. The parameters of  
>> removeMediaListener would then be the pair (addMediaListener result,  
>> callback handler function) and the parameters of the callback handlers  
>> would be the pair (addMediaListener result, query result).
>
> What do you think about that Simon? How would that fit with your  
> bindings?

I have been thinking about this some more and I am no longer convinced the  
complexity is justified. I think using closures is fine. For other  
languages the bindings can be slightly modified to return a token instead  
or something. But there's no need to make the ECMAScript variant more  
complex as well, especially since not all implementations will have  
various languages implementing these bindings, and also since the dominant  
use of this API will be in ECMAScript.


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

Received on Monday, 5 July 2010 08:10:12 UTC