W3C home > Mailing lists > Public > public-device-apis-log@w3.org > January 2017

Re: [sensors] Split parameters between start() and constructor

From: Tobie Langel via GitHub <sysbot+gh@w3.org>
Date: Thu, 26 Jan 2017 12:59:35 +0000
To: public-device-apis-log@w3.org
Message-ID: <issue_comment.created-275382596-1485435573-sysbot+gh@w3.org>
>From a developer experience perspective, I don't think that's an 
optimum solution, as now you have to figure out whether your option is
 immutable or not.

Given extra options won't throw, developers won't even figure out 
what's going on if they make a mistake here. For example, the below 
would default to the implementation specific default, and finding out 
about that would require inspecting the timestamps, storing and 
comparing them.

```js
let gyro = new Gyroscope({ frequency: 60 });
gyro.start();
```

Similarly, in the following scenario, the developer might expect the 
frequency set earlier to stick:

```js
let gyro = new Gyroscope();
gyro.start({ frequency: 60 });
gyro.stop();
gyro.start(); // what's the frequency here? 60 or DEFAULT?
```

For these reasons, I believe an option maybe based on exposing a 
`frequency` attribute or a dedicated `.setFrequency(freq)` method 
might be better. We should investigate it as part of level 2.

-- 
GitHub Notification of comment by tobie
Please view or discuss this issue at 
https://github.com/w3c/sensors/issues/139#issuecomment-275382596 using
 your GitHub account
Received on Thursday, 26 January 2017 12:59:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:34:22 UTC