source: imaps-frontend/node_modules/react-use/esm/useObservable.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 443 bytes
Line 
1import { useState } from 'react';
2import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';
3function useObservable(observable$, initialValue) {
4 var _a = useState(initialValue), value = _a[0], update = _a[1];
5 useIsomorphicLayoutEffect(function () {
6 var s = observable$.subscribe(update);
7 return function () { return s.unsubscribe(); };
8 }, [observable$]);
9 return value;
10}
11export default useObservable;
Note: See TracBrowser for help on using the repository browser.