Files
AFFiNE/packages/frontend/core/src/modules/services.ts
JimmFly 9030ca511e refactor(core): refactor tag to use di (#6079)
use case
```
const tagService = useService(TagService);
const tags = useLiveData(tagService.tags);
const currentTagLiveData = tagService.tagByTagId(tagId);
const currentTag = useLiveData(currentTagLiveData);

```
2024-03-19 08:39:15 +00:00

43 lines
1.2 KiB
TypeScript

import {
GlobalCache,
GlobalState,
PageRecordList,
type ServiceCollection,
Workspace,
WorkspaceScope,
} from '@toeverything/infra';
import { CollectionService } from './collection';
import {
LocalStorageGlobalCache,
LocalStorageGlobalState,
} from './infra-web/storage';
import { Navigator } from './navigation';
import { RightSidebar } from './right-sidebar/entities/right-sidebar';
import { TagService } from './tag';
import { Workbench } from './workbench';
import {
CurrentWorkspaceService,
WorkspaceLegacyProperties,
WorkspacePropertiesAdapter,
} from './workspace';
export function configureBusinessServices(services: ServiceCollection) {
services.add(CurrentWorkspaceService);
services
.scope(WorkspaceScope)
.add(Workbench)
.add(Navigator, [Workbench])
.add(RightSidebar)
.add(WorkspacePropertiesAdapter, [Workspace])
.add(CollectionService, [Workspace])
.add(WorkspaceLegacyProperties, [Workspace])
.add(TagService, [WorkspaceLegacyProperties, PageRecordList]);
}
export function configureWebInfraServices(services: ServiceCollection) {
services
.addImpl(GlobalCache, LocalStorageGlobalCache)
.addImpl(GlobalState, LocalStorageGlobalState);
}