feat(electron): shared storage (#7492)

This commit is contained in:
EYHN
2024-07-15 03:21:08 +00:00
parent 0f1409756e
commit dca88e24fe
22 changed files with 411 additions and 15 deletions

View File

@@ -20,6 +20,12 @@ export interface Memento {
export class MemoryMemento implements Memento {
private readonly data = new Map<string, LiveData<any>>();
setAll(init: Record<string, any>) {
for (const [key, value] of Object.entries(init)) {
this.set(key, value);
}
}
private getLiveData(key: string): LiveData<any> {
let data$ = this.data.get(key);
if (!data$) {
@@ -39,7 +45,9 @@ export class MemoryMemento implements Memento {
this.getLiveData(key).next(value);
}
keys(): string[] {
return Array.from(this.data.keys());
return Array.from(this.data)
.filter(([_, v$]) => v$.value !== undefined)
.map(([k]) => k);
}
clear(): void {
this.data.clear();

View File

@@ -1,7 +1,7 @@
import type { Observable } from 'rxjs';
import { from, merge, of, Subject, throttleTime } from 'rxjs';
import { exhaustMapWithTrailing } from '../../../../utils/exhaustmap-with-trailing';
import { exhaustMapWithTrailing } from '../../../../utils/';
import {
type AggregateOptions,
type AggregateResult,

View File

@@ -4,7 +4,7 @@ import { merge, Observable, of, throttleTime } from 'rxjs';
import { fromPromise } from '../../../../livedata';
import { throwIfAborted } from '../../../../utils';
import { exhaustMapWithTrailing } from '../../../../utils/exhaustmap-with-trailing';
import { exhaustMapWithTrailing } from '../../../../utils/';
import type { Job, JobParams, JobQueue } from '../../';
interface IndexDB extends DBSchema {

View File

@@ -1,5 +1,6 @@
export * from './async-lock';
export * from './async-queue';
export * from './exhaustmap-with-trailing';
export * from './merge-updates';
export * from './object-pool';
export * from './stable-hash';