UNPKG

@towns-protocol/react-sdk

Version:

React Hooks for Towns Protocol SDK

16 lines 629 B
import { useMemo } from 'react'; import { useSyncAgent } from './useSyncAgent'; import { useObservable } from './useObservable'; /** * Hook to get the data of a DM. * You can use this hook to get DM metadata and if the user has joined the DM. * @param streamId - The id of the DM to get the data of. * @param config - Configuration options for the observable. * @returns The DmModel of the DM. */ export const useDm = (streamId, config) => { const sync = useSyncAgent(); const dm = useMemo(() => sync.dms.getDm(streamId), [streamId, sync]); return useObservable(dm, config); }; //# sourceMappingURL=useDm.js.map