Re: Ambient light API redesign

On Mon, Sep 8, 2014 at 1:38 PM, Mounir Lamouri <mounir@lamouri.fr> wrote:

> On Mon, 8 Sep 2014, at 21:24, Tobie Langel wrote:
> > Given the requestAnimationFrame use cases exposed by Rick, it seems that
> > obtaining the Sensor instance immediately is more developer friendly than
> > getting it through a resolved promise. Especially if numerous sensors
> > need
> > to interact.
>
> ```
> sensors = null;
> Promise.all(getSensor1(), getSensor2(), getSensor3()).then(function (s)
> {
>   sensors = s;
> });
>
> requestAnimationFrame(function(frame) {
>   requestAnimationFrame(frame);
>
>   if (!sensors)
>     return;
>
>   [...]
> });
> ```
>

This prevents displaying any data until all sensors have been provided with
an initial value, which is probably not the kind of behavior you want.

--tobie

Received on Monday, 8 September 2014 11:49:00 UTC