2024
React Observable Network Helper
A TypeScript React helper that centralises network-request state, reducing repeated loading, success, and error handling across an application.
- Role
- Creator & Maintainer
- Categories
- Web

Problem
In React applications, every network request can introduce the same repeated state management: tracking loading, success, errors, response data, and error details. As the number of requests grows, this duplication makes components harder to maintain and obscures the request logic.
Approach
I created a small TypeScript helper that centralises request lifecycle management with an observable model. A RequestFactory defines an endpoint, HTTP method, Axios configuration, data mapper, and optional error handler. React components then consume the request through useObservableHttpClient and trigger it with fetchData.
The hook exposes consistent request state - loading, success, error, data, and error response - so components can render the appropriate UI without recreating the same lifecycle logic for every request.
Architecture
The helper creates a request from configuration, executes it as an observable network request, and updates a React hook with the resulting state.

Features
Centralised request state
One request model exposes loading, success, error, data, and error-response state for the consuming component.
Configurable request factory
Define the URL, HTTP method, Axios configuration, mapper, request parameters, request body, and an optional error handler in one place.
React hook integration
Use useObservableHttpClient to subscribe to a request in a component and trigger the request with fetchData.
Typed data mapping
Map an API response to an application model before it is exposed to the component.
Request flow
The request factory and React hook make the request lifecycle explicit: create the request, assign it to the hook, trigger fetchData, and observe the resulting state.

Outcome
The result is a reusable React helper with TypeScript declarations, Axios and RxJS dependencies, documentation diagrams, and an example application. It provides a consistent pattern for handling request state while reducing repeated UI-state code.
Responsibilities
- Designed and implemented the observable request abstraction, request factory, and React hook API.
- Defined the TypeScript package surface and build configuration for library consumption.
- Created the request lifecycle diagrams, setup documentation, and example usage.
- Maintained the public repository and release-ready package documentation.
