Skip to content

AbstractDataManager

A base DataManager to extend when you write your own data manager.

configure subscribes to the measurement stream and calls onMeasurement for each measurement; you implement onMeasurement to store or upload it. Errors on the stream are saved as Error measurements. Emits the DataManagerEventTypes.configured and DataManagerEventTypes.closed events.

Implemented types
Implementers

Constructors

AbstractDataManager

AbstractDataManager()

Properties

dataEndPoint

DataEndPoint? get dataEndPoint

The DataEndPoint that this data manager is handling.

null until configure is called.

deployment

SmartphoneDeployment get deployment
override

The deployment using this data manager.

events

Stream<DataManagerEvent> get events
override

Stream of data manager events, see DataManagerEventTypes.

studyDeploymentId

String get studyDeploymentId
override

The ID of the study deployment that this manager is handling.

Methods

addEvent

void addEvent(
  1. DataManagerEvent event
)

Adds event to the events stream.

close

Future<void> close()
override

Flushes any buffered data and closes this data manager.

After calling close the data manager can no longer be used.

configure

Future<void> configure({
  1. required DataEndPoint dataEndPoint,
  2. required SmartphoneDeployment deployment,
  3. required Stream<Measurement> measurements,
})
override

Configures the data manager with the study deployment, the dataEndPoint, and the stream of measurements to handle.

Call this before any data is handled.

onDone

Future<void> onDone()
override

When the data stream closes, the onDone handler is called. Default implementation is a no-op function. If another behavior is wanted, implementations of this abstract data manager should handle closing of the data stream.

onError

Future<void> onError(
  1. Object? error
)
override

Saves error as an Error measurement via onMeasurement.

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.