mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-04 19:15:33 +08:00
16 lines
395 B
TypeScript
16 lines
395 B
TypeScript
import type { Status, StatusAdapter } from '@affine/y-provider';
|
|
import { useCallback, useSyncExternalStore } from 'react';
|
|
|
|
type UIStatus =
|
|
| Status
|
|
| {
|
|
type: 'unknown';
|
|
};
|
|
|
|
export function useDataSourceStatus(datasource: StatusAdapter): UIStatus {
|
|
return useSyncExternalStore(
|
|
datasource.subscribeStatusChange,
|
|
useCallback(() => datasource.status, [datasource])
|
|
);
|
|
}
|