Nice article, Osman! I love the "learn by creating" approach! and I surely love Rx in React posts 🙂
What do you think if we complete subject on unmount (just to be safe):
constuseObservedValue=value=>{constsubject=React.useRef(newBehaviorSubject(value));React.useEffect(()=>{subject.current.next(value);},[value]);// complete React.useEffect(()=>{return()=>subject.current.complete();},[]);returnReact.useMemo(()=>subject.current.asObservable(),[]);// < no dep, subj is always same};
Just today I've published an article with a bit different approach to RxJS consumption in React: a fragment that observes it's RxJS children, e.g.:
functionApp(){return<$>You're here for {timer(0,1000)} sec</$>}
It subscribes and displays in-place values from it's stream(s). Would be glad to know your thoughts!
Nice article, Osman! I love the "learn by creating" approach!
and I surely love Rx in React posts 🙂
What do you think if we complete subject on unmount (just to be safe):
Just today I've published an article with a bit different approach to RxJS consumption in React: a fragment that observes it's RxJS children, e.g.:
It subscribes and displays in-place values from it's stream(s). Would be glad to know your thoughts!
Here's a 5min post if you're interested:
Fetching Data in React with RxJS and <$> fragment
Kostia Palchyk for RxJS ・ Aug 4 '20 ・ 5 min read