voicebot-react-native-expo
Version:
This is a voicebot-react-native package of Kipps AI voice bot for React Native Expo
18 lines (16 loc) • 587 B
text/typescript
import * as React from 'react';
import { type TrackReferenceOrPlaceholder, trackSyncTimeObserver } from '@livekit/components-core';
import { useObservableState } from './internal';
/**
* @internal
*/
export function useTrackSyncTime(ref: TrackReferenceOrPlaceholder | undefined) {
const observable = React.useMemo(
() => (ref?.publication?.track ? trackSyncTimeObserver(ref?.publication.track) : undefined),
[ref?.publication?.track],
);
return useObservableState(observable, {
timestamp: Date.now(),
rtpTimestamp: ref?.publication?.track?.rtpTimestamp,
});
}