We've gone to great lengths to adhere to the Raj community best practices.
For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
How it works
This is a Create React App app. The code lives mainly in
programshas the application pages and the navigation header
routingcontains the router and utilities for handling links and navigation
remotehandles the API business
viewscontains the shared view components
errorscontains the error handling
Side-effects are pushed to the edge of the system. The asynchronous code lives in the
routerservices. These can be swapped out with dummy services in testing.
Error handling is accomplished with a high-order-program (HOP). We wrap each program and the
withErrorsprogram manages the UI bits. This works because errors are not too important in RealWorld. An app with i18n requirements would have a fair amount of hand rolled error handling.
The links and routes are not hard-coded. We can rename routing table entries and everything would still work. Using push-state would require little changes.
There are quite a few ways to write a REST API integration. The
remotecontains everything, but effects can be fragmented and local to programs. The approach taken here is good, not gospel.
We do not request the user on every page transition. The
remotehas internal state for caching the current user. Since this state is hidden from the application code, it is fine.
yarn install # development yarn start # build yarn run build