Skip to content

Instantly share code, notes, and snippets.

@tobie
Last active October 28, 2015 00:48
Show Gist options
  • Save tobie/11cf06b819544f71fe36 to your computer and use it in GitHub Desktop.
Save tobie/11cf06b819544f71fe36 to your computer and use it in GitHub Desktop.
Door Sensor + Actuator example.
[Constructor(VehicleSensorOptions options), Exposed=(Window,Worker)]
interface VehicleSensor : Sensor {
};
dictionary VehicleSensorOptions : SensorOptions {
VehicleZone zone;
};
interface VehiclePart : VehicleSensor {
Promise<void> set(value);
};
interface Door : VehiclePart {
readonly attribute DoorSensorReading? value;
};
interface DoorSensorReading : SensorReading {
readonly attribute boolean isLocked;
};
let door = new VehicleDoor({ zone: "front left" });
door.onchange = e => {
let status = e.isLocked ? "locked" : "unlocked";
console.log("Front left door is now " + status);
}
@tobie
Copy link
Author

tobie commented Oct 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment