mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-13 08:06:24 +08:00
16 lines
387 B
TypeScript
16 lines
387 B
TypeScript
import { useCallback, useSyncExternalStore } from 'react';
|
|
import type { DataSourceAdapter, Status } from 'y-provider';
|
|
|
|
type UIStatus =
|
|
| Status
|
|
| {
|
|
type: 'unknown';
|
|
};
|
|
|
|
export function useDataSourceStatus(provider: DataSourceAdapter): UIStatus {
|
|
return useSyncExternalStore(
|
|
provider.subscribeStatusChange,
|
|
useCallback(() => provider.status, [provider])
|
|
);
|
|
}
|