Apollo inspired library to connect redux, local-storage, and rest domains seamlessly.
It is a library to attempt to make life easier by reducing boilerplate introduced with Redux + API connections.
- Tracking Rest executions (does not execute same command twice).
- Exclusive use of hooks for clean code.
- Persisting data in a redux store.
- Persisting data over refreshes (localstorage).
- Has intervals.
- Has manually fetching.
- Exposes native libraries.
Minimize the laundry list of dependencies.
npm install --save d-man
Example here
import React from 'react';
import { createDMan } from 'd-man';
const { Provider, domain } = createDMan({
domain: {
baseURL: 'https://jsonplaceholder.typicode.com',
},
});
const Todos = () => {
const { data: todos, loading } = domain.useGet('/todos');
if (loading) {
return <div>Loading...</div>
}
return (
<table>
<thead>
<tr>
<th>Title</th>
<th>Completed</th>
</tr>
</thead>
<tbody>
{todos.map((todo: any) => (
<tr key={todo.id}>
<td>{todo.title}</td>
<td>{todo.completed && 'X'}</td>
</tr>
))}
</tbody>
</table>
);
};
const App = () => (
<Provider>
<Todos />
</Provider>
);
export default App;
MIT © vssrcj