mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
594 B
TypeScript
25 lines
594 B
TypeScript
import { useEffect } from 'react';
|
|
import { fetchAvailableServices } from '../../model/common';
|
|
import { useAsyncFn } from '../useAsyncFn';
|
|
import { useMemoizedFn } from '../useMemoizedFn';
|
|
|
|
/**
|
|
* 用于监测服务是否可用的hooks
|
|
*/
|
|
export function useAvailableServices() {
|
|
const [{ loading, value: availableServices }, fetch] = useAsyncFn(() =>
|
|
fetchAvailableServices()
|
|
);
|
|
|
|
useEffect(() => {
|
|
fetch();
|
|
}, []);
|
|
|
|
const refetch = useMemoizedFn(async () => {
|
|
fetchAvailableServices.clearCache();
|
|
fetch();
|
|
});
|
|
|
|
return { loading, availableServices, refetch };
|
|
}
|