A sum type for managing asynchronous data states in a functional programming style.
Represents four states: success (Data), loading (Query), empty (Empty), or failure (Failure).
Supports functor, applicative functor, and monad operations for declarative transformations.
Designed for use with Redux Toolkit, Redux Observables, and React.
Type Param: T
The type of the data in Data state.
Type Param: Q
The type of optional parameters (e.g., query params for API calls).
Example
// Create a Resource for a user fetch constuserResource = Resource.Data({ id:'123', name:'Jane' }, { endpoint:'/users' });
// Transform data with map constupperCaseName = userResource.map(user=> ({ ...user, name:user.name.toUpperCase() }));
A sum type for managing asynchronous data states in a functional programming style. Represents four states: success (
Data
), loading (Query
), empty (Empty
), or failure (Failure
). Supports functor, applicative functor, and monad operations for declarative transformations. Designed for use with Redux Toolkit, Redux Observables, and React.Type Param: T
The type of the data in
Data
state.Type Param: Q
The type of optional parameters (e.g., query params for API calls).
Example