-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split parameters between start() and constructor #139
Comments
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. let gyro = new Gyroscope({ frequency: 60 });
gyro.start(); Similarly, in the following scenario, the developer might expect the frequency set earlier to stick: 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 |
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: