Table of Contents

Class PressureObserver

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The PressureObserver interface is part of the Compute Pressure API and is used to observe the pressure changes of system resources such as the CPU.
[Value("PressureObserver")]
public class PressureObserver
Inheritance
PressureObserver
Inherited Members

Remarks

-'PerformanceObserver'
-'MutationObserver'
-'ResizeObserver'
-'IntersectionObserver'

See also on MDN

Constructors

PressureObserver()

public PressureObserver()

PressureObserver(PressureUpdateCallback)

NOTE
Experimental
The PressureObserver() constructor creates a new PressureObserver object to watch for changes to pressure changes of system resources such as the CPU.
public PressureObserver(PressureUpdateCallback callback)

Parameters

callback PressureUpdateCallback

Remarks

Properties

KnownSources

NOTE
Experimental
The static knownSources read-only property of the PressureObserver interface returns an array of the Source values supported by the user agent in alphabetical order.
[Value("knownSources")]
public static PressureSource[] KnownSources { get; }

Property Value

PressureSource[]

An array of Source values.

Remarks

NOTE

The list of supported sources varies per browser, operating system, and hardware, and is evolving. This property is merely a hint about source types the user agents supports. Call Observe(PressureSource, PressureObserverOptions) and check for a NotSupportedError to see if pressure observation is possible.

See also on MDN

Methods

Disconnect()

NOTE
Experimental
The disconnect() method of the 'PressureObserver' interface stops the pressure observer callback from receiving pressure records from all sources.
[Value("disconnect")]
public GlobalObject.Undefined Disconnect()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Observe(PressureSource, PressureObserverOptions)

NOTE
Experimental
The observe() method of the PressureObserver interface tells the pressure observer to start observing pressure changes. After this method is called, the observer will call its callback function when a pressure record for the specified source is observed.
[Value("observe")]
public Task<GlobalObject.Undefined> Observe(PressureSource source, PressureObserverOptions options = null)

Parameters

source PressureSource
options PressureObserverOptions

Returns

Task<GlobalObject.Undefined>

A Promise that fulfils with GlobalObject.Undefined.

Remarks

When a matching PressureRecord is obtained, the pressure observer's callback function is invoked.

See also on MDN

TakeRecords()

NOTE
Experimental
The takeRecords() method of the 'PressureObserver' interface returns the current list of pressure records stored in the pressure observer, emptying it out.
[Value("takeRecords")]
public List<PressureRecord> TakeRecords()

Returns

List<PressureRecord>

An {{jsxref("Array")}} of PressureRecord objects.

Remarks

It is useful when you want to a stop observing a source but would like to be sure to get any records that have not yet been passed into the observer callback.

See also on MDN

Unobserve(PressureSource)

NOTE
Experimental
The unobserve() method of the 'PressureObserver' interface stops the pressure observer callback from receiving pressure records from the specified source.
[Value("unobserve")]
public GlobalObject.Undefined Unobserve(PressureSource source)

Parameters

source PressureSource

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks