Skip to content

Commit

Permalink
feat: Init RxJS
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydrichards committed Sep 6, 2020
1 parent 8c20902 commit 84742cd
Show file tree
Hide file tree
Showing 5 changed files with 869 additions and 1 deletion.
13 changes: 13 additions & 0 deletions components/helpers/useObservable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Observable } from "rxjs"
import { Dispatch, SetStateAction, useEffect } from "react";

const useObservable = (observable: Observable<any>, setter: Dispatch<SetStateAction<any>>) => {
useEffect(()=>{
let subscription = observable.subscribe(result => {
setter(result);
});
return ()=> subscription.unsubscribe()
},[observable, setter])
}

export default useObservable
Loading

0 comments on commit 84742cd

Please sign in to comment.