You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two types of information that might be required by the Sensor object: construction parameters that are persistent during the lifetime of a sensor and parameters that web developer can change after sensor is constructed. By moving SensorOptions to the start() method, Generic Sensor API would allow web developers to change e.g. frequency hint for the sensor without the need to re-construct the object.
Example:
// Construction parameters that are immutable during sensor's lifetime.
let gyro = new Gyroscope({uncalibrated: true});
// Platform selects default frequency hint.
gyro.start();
gyro.stop();
// Provide 30Hz frequency hint.
gyro.start({frequency: 30});
gyro.stop();
The text was updated successfully, but these errors were encountered:
tobie
changed the title
Split construction parameters and parameters that can be changed at runtime
Split parameters between start() and constructor
Oct 28, 2016
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.
Similarly, in the following scenario, the developer might expect the frequency set earlier to stick:
letgyro=newGyroscope();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.
This issue discusses a generic solution to change parameters after the sensor is constructed, of which #63 was a special case of. Since the group did a decision to defer #63 back to Level 2, also this generic issue logically follows that decision.
There are two types of information that might be required by the Sensor object: construction parameters that are persistent during the lifetime of a sensor and parameters that web developer can change after sensor is constructed. By moving SensorOptions to the start() method, Generic Sensor API would allow web developers to change e.g. frequency hint for the sensor without the need to re-construct the object.
Example:
The text was updated successfully, but these errors were encountered: