starter.dev-github-showcases
starter.dev-github-showcases copied to clipboard
[cra-rxjs-sc] Improve where observables are created
We should create the observables outside of the components/hooks. Though it can be tempting to create the observables in components like in RepoPage.data.tsx or UserProvider.tsx, or in hooks like useSetToken() and useRepositoryIssues(), I have found it far better separate the "react" code from the RxJS code and combine them where necessary with a useObservable() or similar hook.
This makes testing easier, and reduces the complexity, as anything with asynchronous state can done in RxJS and leave the visual UI and component state to react.