Table of Contents

Class Sensor

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The Sensor interface of the Sensor APIs is the base class for all the other sensor interfaces. This interface cannot be used directly. Instead it provides properties, event handlers, and methods accessed by interfaces that inherit from it.

[Value("Sensor")]
public class Sensor : EventTarget
Inheritance
Sensor
Derived
Inherited Members

Remarks

This feature may be blocked by a Permissions Policy set on your server.

When initially created, the Sensor object is idle, meaning it does not take measures. Once the Start() method is called, it prepares itself to read data and, once ready, the Sensoractivate event is sent and the sensor becomes activated. It then sends a Sensorreading event each time new data is available.

In case of an error, the Sensorerror event is sent, reading stops, and the Sensor object becomes idle again. The Start() method needs to be called again before it can read further data.

See also on MDN

Constructors

Sensor()

public Sensor()

Properties

Activated

The activated read-only property
of the Sensor interface returns a boolean value indicating
whether the sensor is active.

[Value("activated")]
public bool Activated { get; }

Property Value

bool

A boolean value.

Remarks

Because 'Sensor' is a base class, activated may only be read
from one of its derived classes.

See also on MDN

HasReading

The hasReading read-only
property of the Sensor interface returns a boolean value
indicating whether the sensor has a reading.

[Value("hasReading")]
public bool HasReading { get; }

Property Value

bool

A boolean value.

Remarks

Because 'Sensor' is a base class, hasReading may only be read
from one of its derived classes.

See also on MDN

Onactivate

[Value("onactivate")]
public EventHandlerNonNull Onactivate { get; set; }

Property Value

EventHandlerNonNull

Onerror

[Value("onerror")]
public EventHandlerNonNull Onerror { get; set; }

Property Value

EventHandlerNonNull

Onreading

[Value("onreading")]
public EventHandlerNonNull Onreading { get; set; }

Property Value

EventHandlerNonNull

Timestamp

The timestamp read-only property
of the Sensor interface returns the timestamp of the latest sensor
reading.

[Value("timestamp")]
public Number? Timestamp { get; }

Property Value

Number

A Number.

Remarks

Because 'Sensor' is a base class, timestamp may only be read
from one of its derived classes.

See also on MDN

Methods

Start()

The start() method of the Sensor interface activates one of the sensors based on Sensor.

[Value("start")]
public GlobalObject.Undefined Start()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Stop()

The stop() method of the Sensor interface deactivates the current sensor.

[Value("stop")]
public GlobalObject.Undefined Stop()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks