TinyBase logoTinyBase

getConnection

The getConnection method returns the PartySocket the Store is being persisted to.

getConnection(): PartySocket
returnsPartySocket

The PartySocket.

Example

This example creates a Persister object against a newly-created Store and then gets the PartySocket back out again.

import {PartySocket} from 'partysocket';
import {createPartyKitPersister} from 'tinybase/persisters/persister-partykit-client';
import {createStore} from 'tinybase';

const partySocket = new PartySocket({
  host: '127.0.0.1:1999',
  room: 'my_room',
});
const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
const persister = createPartyKitPersister(store, partySocket);

console.log(persister.getConnection() == partySocket);
// -> true

persister.destroy();

Since

v4.3.14