[Bug 26372] Report issues/events not related to a specific method call

https://www.w3.org/Bugs/Public/show_bug.cgi?id=26372

--- Comment #27 from Boris Zbarsky <bzbarsky@mit.edu> ---
> In this case, this seems equivalent to a simple event with an attribute or
> method to query, right?

Yes, except it acts like "normal" JS objects from the API consumer's point of
view.

> but is such a solution really better than having a simple event (or promise, as
> is the case for |closed|) for each one?

That's an API design decision in the end.

I would say that for state that is synchronously available and easily computed
using Object.observe is probably the right way forward in terms of creating
developer-friendly APIs.

For state that is not synchronously available, promises seem like the right
approach.

> What if MediaKeySession had a method named getKeys() that
> returned (a reference to) an array of key IDs that could then be observed.

API like this is possible to create, but there are some gotchas that you need
to be careful with.  For example, what would happen if the script mutated this
array?  Would this affect other callers of getKeys(), or would each getKeys()
call return a new array?  Both answers have some problems, fwiw: in the former
case, if the return value of getKeys() can change you have to define exactly
how the array is updated, while in the latter case if the value changes you
have to update all the different arrays you ever returned.

> Is there something like a map already defined that we could use?

ES has a Map object, but I don't believe changes to the map are observable
sanely via Object.observe.

> Object.observe() allows applications to be informed of the exact change and
> take action, but it probably adds some TBD amount of complexity to the spec.

I don't think it adds any more complexity than firing a DOM event, at least
once someone writes a generic "send an observer notification" hook in the DOM
spec.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Tuesday, 23 September 2014 00:26:04 UTC