mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-13 12:54:59 +08:00
style: enable rxjs/finnish (#6276)
chore(infra): use finnish notation for observables do rename
This commit is contained in:
@@ -38,9 +38,9 @@ export const db$Map = new Map<string, Observable<WorkspaceSQLiteDB>>();
|
||||
const beforeQuit$ = defer(() => fromEvent(process, 'beforeExit'));
|
||||
|
||||
// return a stream that emit a single event when the subject completes
|
||||
function completed<T>(subject: Subject<T>) {
|
||||
function completed<T>(subject$: Subject<T>) {
|
||||
return new Observable(subscriber => {
|
||||
const sub = subject.subscribe({
|
||||
const sub = subject$.subscribe({
|
||||
complete: () => {
|
||||
subscriber.next();
|
||||
subscriber.complete();
|
||||
@@ -50,7 +50,7 @@ function completed<T>(subject: Subject<T>) {
|
||||
});
|
||||
}
|
||||
|
||||
function getWorkspaceDB$(id: string) {
|
||||
function getWorkspaceDB(id: string) {
|
||||
if (!db$Map.has(id)) {
|
||||
db$Map.set(
|
||||
id,
|
||||
@@ -103,7 +103,7 @@ function getWorkspaceDB$(id: string) {
|
||||
function startPollingSecondaryDB(db: WorkspaceSQLiteDB) {
|
||||
return merge(
|
||||
getWorkspaceMeta(db.workspaceId),
|
||||
workspaceSubjects.meta.pipe(
|
||||
workspaceSubjects.meta$.pipe(
|
||||
map(({ meta }) => meta),
|
||||
filter(meta => meta.id === db.workspaceId)
|
||||
)
|
||||
@@ -141,5 +141,5 @@ function startPollingSecondaryDB(db: WorkspaceSQLiteDB) {
|
||||
}
|
||||
|
||||
export function ensureSQLiteDB(id: string) {
|
||||
return lastValueFrom(getWorkspaceDB$(id).pipe(take(1)));
|
||||
return lastValueFrom(getWorkspaceDB(id).pipe(take(1)));
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export const dbEvents = {
|
||||
docId?: string;
|
||||
}) => void
|
||||
) => {
|
||||
const sub = dbSubjects.externalUpdate.subscribe(fn);
|
||||
const sub = dbSubjects.externalUpdate$.subscribe(fn);
|
||||
return () => {
|
||||
sub.unsubscribe();
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
export const dbSubjects = {
|
||||
externalUpdate: new Subject<{
|
||||
externalUpdate$: new Subject<{
|
||||
workspaceId: string;
|
||||
update: Uint8Array;
|
||||
docId?: string;
|
||||
|
||||
@@ -66,7 +66,7 @@ export class WorkspaceSQLiteDB extends BaseSQLiteAdapter {
|
||||
if (origin === 'renderer') {
|
||||
await this.addUpdateToSQLite(insertRows);
|
||||
} else if (origin === 'external') {
|
||||
dbSubjects.externalUpdate.next({
|
||||
dbSubjects.externalUpdate$.next({
|
||||
workspaceId: this.workspaceId,
|
||||
update,
|
||||
docId,
|
||||
|
||||
@@ -97,7 +97,7 @@ export async function storeWorkspaceMeta(
|
||||
...meta,
|
||||
};
|
||||
await fs.writeJSON(metaPath, newMeta);
|
||||
workspaceSubjects.meta.next({
|
||||
workspaceSubjects.meta$.next({
|
||||
workspaceId,
|
||||
meta: newMeta,
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ export const workspaceEvents = {
|
||||
onMetaChange: (
|
||||
fn: (meta: { workspaceId: string; meta: WorkspaceMeta }) => void
|
||||
) => {
|
||||
const sub = workspaceSubjects.meta.subscribe(fn);
|
||||
const sub = workspaceSubjects.meta$.subscribe(fn);
|
||||
return () => {
|
||||
sub.unsubscribe();
|
||||
};
|
||||
|
||||
@@ -3,5 +3,5 @@ import { Subject } from 'rxjs';
|
||||
import type { WorkspaceMeta } from '../type';
|
||||
|
||||
export const workspaceSubjects = {
|
||||
meta: new Subject<{ workspaceId: string; meta: WorkspaceMeta }>(),
|
||||
meta$: new Subject<{ workspaceId: string; meta: WorkspaceMeta }>(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user