starter.dev-github-showcases icon indicating copy to clipboard operation
starter.dev-github-showcases copied to clipboard

[cra-rxjs-sc] Improve where observables are created

Open Atrophius opened this issue 3 years ago • 0 comments

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.

Atrophius avatar Sep 12 '22 15:09 Atrophius