connectToEndpoint static method
Connect to an endpoint obtained through exposeEndpoint.
The endpoint is transferrable in JavaScript, allowing multiple JavaScript contexts to exchange opened database connections.
Implementation
static Future<WebSqliteConnection> connectToEndpoint(
WebDatabaseEndpoint endpoint) async {
final rawSqlite = await WebSqlite.connectToPort(
(endpoint.connectPort, endpoint.connectName));
final database = WebDatabase(
rawSqlite,
switch (endpoint.lockName) {
var lock? => Mutex(identifier: lock),
null => null,
},
);
return database;
}