@liveblocks/react-ui
Version:
A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.
14 lines (11 loc) • 415 B
JavaScript
import { useLatest } from '@liveblocks/react/_private';
import { useEffect } from 'react';
function useObservable(observable, callback) {
const latestCallback = useLatest(callback);
useEffect(() => {
const unsubscribe = observable.subscribe(() => latestCallback.current());
return unsubscribe;
}, [observable, latestCallback]);
}
export { useObservable };
//# sourceMappingURL=use-observable.js.map