TinyBase logoTinyBase

getSynchronizerStats

The getSynchronizerStats method provides a set of statistics about the Synchronizer, and is used for debugging purposes.

getSynchronizerStats(): SynchronizerStats
returnsSynchronizerStats

A SynchronizerStats object containing Synchronizer send and receive statistics.

The SynchronizerStats object contains a count of the number of times the Synchronizer has sent and received messages.

The method is intended to be used during development to ensure your synchronization layer is acting as expected, for example.

Example

This example gets the send and receive statistics of two active Synchronizer instances.

import {createLocalSynchronizer} from 'tinybase/synchronizers/synchronizer-local';
import {createMergeableStore} from 'tinybase';

const store1 = createMergeableStore();
const store2 = createMergeableStore();

const synchronizer1 = createLocalSynchronizer(store1);
const synchronizer2 = createLocalSynchronizer(store2);

await synchronizer1.startSync();
await synchronizer2.startSync();

store1.setTables({pets: {fido: {species: 'dog'}}});
// ...
store2.setRow('pets', 'felix', {species: 'cat'});
// ...

console.log(synchronizer1.getSynchronizerStats());
// -> {receives: 4, sends: 5}
console.log(synchronizer2.getSynchronizerStats());
// -> {receives: 5, sends: 4}

synchronizer1.destroy();
synchronizer2.destroy();

Since

v5.0.0