W3C home > Mailing lists > Public > public-secondscreen@w3.org > June 2016

Re: [remote-playback] Do we need remote.getAvailability()?

From: Anton Vayvod via GitHub <sysbot+gh@w3.org>
Date: Wed, 29 Jun 2016 07:41:41 +0000
To: public-secondscreen@w3.org
Message-ID: <issue_comment.created-229073637-1467125513-sysbot+gh@w3.org>
I've looked at the IntersectionObserver and IDBObserver. Both seem a 
bit too complex for our use case, creating new objects and all. I 
think I'd settle for using what Mark initially proposed - live 
```availability``` attribute with an unknown value for when the state 
is unobserved or the media element source has changed, but using an 
observer pattern to work around the event handler issue of having to 
dispatch a fake change event for the listeners attached when the 
availability is known:

```webidl

enum RemotePlaybackAvailability {
    "available",
    "unavailable",
    "unknown"
};

partial interface RemotePlayback {
    // "unknown" if there's no callbacks observing its changes or if 
observers are not supported.
    // May become "available" or "unavailable" if and only if there're
 any observers registered with
    // |observeAvailability|.
    readonly attribute RemotePlaybackAvailability availability;

    // The returned promise is fullfilled if the website should expect
 the callback to be called,
    // meaning the background monitoring of remote playback device 
availability is supported.
    // The |availability| may now change from "unknown" to other 
values.
    Promise<void> 
observeAvailability(RemotePlaybackAvailabilityCallback callback);

    // Stops calling the specified |callback| whenever |availability| 
changes. May stop the background
    // availability monitoring and change |availability| to "unknown".
    // If no callback is specified, stops calling any callbacks and 
changes |availability| to "unknown".
    // |availability| becomes "unknown".
    void unobserveAvailability(optional 
RemotePlaybackAvailabilityCallback callback);
};

// |available| is the new value that indicates if the devices are now 
available or not
// for the |element|.
callback RemotePlaybackAvailabilityCallback = void(boolean available);
```

In the essence this adds special versions 
addEventListener/removeEventListener methods to RemotePlayback to 
workaround the "adding/removing event handlers should have no side 
effects" rule.

-- 
GitHub Notification of comment by avayvod
Please view or discuss this issue at 
https://github.com/w3c/remote-playback/issues/39#issuecomment-229073637
 using your GitHub account
Received on Wednesday, 29 June 2016 07:41:49 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 29 June 2016 07:41:50 UTC