Skip to content

BufferingPeriodicStreamProbe

A probe that buffers a bufferingStream in sampling windows.

It emits one measurement per window. Uses a PeriodicSamplingConfiguration: every PeriodicSamplingConfiguration.interval it calls onSamplingStart and listens to bufferingStream for PeriodicSamplingConfiguration.duration. Each event goes to onSamplingData. When the window ends, it calls onSamplingEnd and adds the result of getMeasurement.

Unlike BufferingIntervalStreamProbe, it listens to bufferingStream only inside sampling windows. See LightProbe for an example, which turns the light readings of each window into one AmbientLight measurement.

Inheritance
Implementers

Constructors

BufferingPeriodicStreamProbe

BufferingPeriodicStreamProbe()

Properties

bufferingStream

Stream get bufferingStream

The stream of events to buffer. Implemented by subclasses.

stream

Stream<Measurement> get stream
override

The stream of Measurements to forward. Implemented by subclasses.

Read on the first resume after creation or a pause.

Methods

getMeasurement

Future<Measurement?> getMeasurement()

Returns the Measurement for the last sampling window.

Implemented by subclasses.

Can return null if no data is available. Can return an Error if an error occurs.

onPause

Future<bool> onPause()
override

Called by pause. Returns true if successfully paused.

If false, the state is not changed.

onResume

Future<bool> onResume()
override

Called by resume. Returns true if successfully resumed.

If false, the executor moves to ExecutorState.PausedButShouldBeResumed.

onSamplingData

void onSamplingData(
  1. dynamic event
)

Called for each event on bufferingStream; buffers it.

onSamplingEnd

void onSamplingEnd()

Called when a sampling window ends, before getMeasurement.

onSamplingStart

void onSamplingStart()

Called when a sampling window starts, before listening.