mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-29 08:09:52 +08:00
24 lines
577 B
TypeScript
24 lines
577 B
TypeScript
import type { Awareness } from 'y-protocols/awareness.js';
|
|
|
|
export interface AwarenessConnection {
|
|
connect(awareness: Awareness): void;
|
|
disconnect(): void;
|
|
dispose?(): void;
|
|
}
|
|
|
|
export class AwarenessEngine {
|
|
constructor(public readonly connections: AwarenessConnection[]) {}
|
|
|
|
connect(awareness: Awareness) {
|
|
this.connections.forEach(connection => connection.connect(awareness));
|
|
}
|
|
|
|
disconnect() {
|
|
this.connections.forEach(connection => connection.disconnect());
|
|
}
|
|
|
|
dispose() {
|
|
this.connections.forEach(connection => connection.dispose?.());
|
|
}
|
|
}
|