TinyBase logoTinyBase

createMetrics

The createMetrics function creates a Metrics object, and is the main entry point into the metrics module.

createMetrics(store: Store): Metrics
TypeDescription
storeStore

The Store for which to register Metric definitions.

returnsMetrics

A reference to the new Metrics object.

A given Store can only have one Metrics object associated with it. If you call this function twice on the same Store, your second call will return a reference to the Metrics object created by the first.

Examples

This example creates a Metrics object.

const store = createStore();
const metrics = createMetrics(store);
console.log(metrics.getMetricIds());
// -> []

This example creates a Metrics object, and calls the method a second time for the same Store to return the same object.

const store = createStore();
const metrics1 = createMetrics(store);
const metrics2 = createMetrics(store);
console.log(metrics1 === metrics2);
// -> true