TinyBase logoTinyBase

MetricListener

The MetricListener type describes a function that is used to listen to changes to a Metric.

(
  metrics: Metrics,
  metricId: Id,
  newMetric: Metric | undefined,
  oldMetric: Metric | undefined,
): void
TypeDescription
metricsMetrics

A reference to the Metrics object that changed.

metricIdId

The Id of the Metric that changed.

newMetricMetric | undefined

The new value of the Metric that changed.

oldMetricMetric | undefined

The old value of the Metric that changed.

returnsvoid

This has no return value.

A MetricListener is provided when using the addMetricListener method. See that method for specific examples.

When called, a MetricListener is given a reference to the Metrics object, the Id of the Metric that changed, and the new and old values of the Metric.

If this is the first time that a Metric has had a value (such as when a table has gained its first row), the old value will be undefined. If a Metric now no longer has a value, the new value will be undefined.