mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
feat(infra): framework
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import { ServiceCollection } from '../../di';
|
||||
import { GlobalCache, GlobalState, MemoryMemento } from '..';
|
||||
import { MemoryMemento } from '..';
|
||||
|
||||
describe('memento', () => {
|
||||
test('memory', () => {
|
||||
@@ -23,18 +22,4 @@ describe('memento', () => {
|
||||
memento.set('foo', 'hello');
|
||||
expect(subscribed).toEqual('baz');
|
||||
});
|
||||
|
||||
test('service', () => {
|
||||
const services = new ServiceCollection();
|
||||
|
||||
services
|
||||
.addImpl(GlobalCache, MemoryMemento)
|
||||
.addImpl(GlobalState, MemoryMemento);
|
||||
|
||||
const provider = services.provider();
|
||||
const cache = provider.get(GlobalCache);
|
||||
expect(cache).toBeInstanceOf(MemoryMemento);
|
||||
const state = provider.get(GlobalState);
|
||||
expect(state).toBeInstanceOf(MemoryMemento);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { Observable } from 'rxjs';
|
||||
|
||||
import { createIdentifier } from '../di';
|
||||
import { LiveData } from '../livedata';
|
||||
|
||||
/**
|
||||
@@ -15,24 +14,6 @@ export interface Memento {
|
||||
keys(): string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A memento object that stores the entire application state.
|
||||
*
|
||||
* State is persisted, even the application is closed.
|
||||
*/
|
||||
export interface GlobalState extends Memento {}
|
||||
|
||||
export const GlobalState = createIdentifier<GlobalState>('GlobalState');
|
||||
|
||||
/**
|
||||
* A memento object that stores the entire application cache.
|
||||
*
|
||||
* Cache may be deleted from time to time, business logic should not rely on cache.
|
||||
*/
|
||||
export interface GlobalCache extends Memento {}
|
||||
|
||||
export const GlobalCache = createIdentifier<GlobalCache>('GlobalCache');
|
||||
|
||||
/**
|
||||
* A simple implementation of Memento. Used for testing.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user