-
-
Save tobie/11cf06b819544f71fe36 to your computer and use it in GitHub Desktop.
Door Sensor + Actuator example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let door = new VehicleDoor({ zone: "front left" }); | |
door.onchange = e => { | |
let status = e.isLocked ? "locked" : "unlocked"; | |
console.log("Front left door is now " + status); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/cc @acrofts84