# 9. Cache latest data for sensors

Date: 2023-02-16

## Status

Accepted

## Context

Driver APIs, like the GPS, are designed in a synchronous manner even though they operate asynchronously. With the event system, we have an opportunity to create a new operational model that simplifies the development and usage flow.

## Decision

Rather than passing events with data or managing queues, the latest sample will be cached in the driver and retrieved via an API. 

`requestX()` functions will update the cached data when the operation completes, and an event will be generated that notifies clients that the data is ready.

## Consequences

- When data ready events are received, for most cases, the proper response will then be to invoke the appropriate API on the driver to get the latest sample.
- Clients will need to check the timestamp to determine whether the sample is recent enough. If not, new samples can be requested via the request API.
