mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat: jwst connectivity
This commit is contained in:
@@ -23,6 +23,13 @@ export abstract class ServiceBaseClass {
|
||||
return db.getWorkspace();
|
||||
}
|
||||
|
||||
async listenConnectivity(
|
||||
workspace: string,
|
||||
callback: (state: string) => void
|
||||
) {
|
||||
this.database.listenConnectivity(workspace, workspace, callback);
|
||||
}
|
||||
|
||||
async onHistoryChange(
|
||||
workspace: string,
|
||||
name: string,
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
BlockContentExporter,
|
||||
BlockMatcher,
|
||||
BlockInitOptions,
|
||||
Connectivity,
|
||||
} from '@toeverything/datasource/jwt';
|
||||
import { sleep } from '@toeverything/utils';
|
||||
|
||||
@@ -81,6 +82,18 @@ export class Database {
|
||||
return db;
|
||||
}
|
||||
|
||||
async listenConnectivity(
|
||||
workspace: string,
|
||||
name: string,
|
||||
listener: (connectivity: Connectivity) => void
|
||||
) {
|
||||
const db = await _getBlockDatabase(workspace);
|
||||
return db.addConnectivityListener(name, state => {
|
||||
const connectivity = state.get(name);
|
||||
if (connectivity) listener(connectivity);
|
||||
});
|
||||
}
|
||||
|
||||
async registerContentExporter(
|
||||
workspace: string,
|
||||
name: string,
|
||||
|
||||
Reference in New Issue
Block a user