PressureObserver: takeRecords() method
Compute Pressure APIwindowandworkerexceptservice
Compute Pressure APIwindow_and_worker_except_service
The **`takeRecords()`** method of the PressureObserver interface returns the current list of pressure records stored in the pressure observer, emptying it out.
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.
## Syntax
```js-nolint
takeRecords()
```
### Parameters
None.
### Return value
An Array of PressureRecord objects.
## Examples
### Taking records
The following example stores the current list of pressure records into `records` and empties the pressure observer.
```js
const observer = new PressureObserver(callback);
observer.observe("cpu");
const records = observer.takeRecords();
observer.disconnect(); // shut down observer now that we've taken records
if (records.length > 0) {
console.log(records[0].state);
console.log(records[0].time);
}
```
## Specifications
## Browser compatibility
Cite this
"PressureObserver: takeRecords() method". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/PressureObserver/takeRecords JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy