d-man
TypeScript icon, indicating that this package has built-in type declarations

0.3.10 • Public • Published

d-man

Apollo inspired library to connect redux, local-storage, and rest domains seamlessly.

NPM JavaScript Style Guide

What is this?

It is a library to attempt to make life easier by reducing boilerplate introduced with Redux + API connections.

Features

  • 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.

Todo!

Minimize the laundry list of dependencies.

Install

npm install --save d-man

Simplest Usage

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;

License

MIT © vssrcj

Readme

Keywords

none

Package Sidebar

Install

npm i d-man

Weekly Downloads

0

Version

0.3.10

License

MIT

Unpacked Size

268 kB

Total Files

25

Last publish

Collaborators

  • vssrcj