* move @toeverything/hooks -> @affine/core/hooks * delete @toeverything/hooks hooks are all business-related logic and are deeply coupled with other parts. Move them into the core and then reconstruct them by feature.
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])
|
|
);
|
|
}
|