networked

0.0.1 • Public • Published

networked

A simple React hook to be wrapped around API calls for simple retries and queuing.

WIP

Usage

Initalize Hook with Options

import createUseNetwork from 'networked';
// hooks/use-network.js;

export default createUseNetwork({
 maxRetries: [Int, default = 3], // Changing this to null will make the hook constantly attempt to reconnect, otherwise, none of the calls will be attempted again until another network call is made, which will restart the retry process.
 queue: [Boolean, default = true]
});

Component

import useNetwork from 'hooks/use-network.js';
 
...[some arbitrary component-related code here]

const { execute, error, isLoading } = useNetwork(
  async () => {
    await (make API call here)
  }
)

...[some arbitrary component-related code here]

Dependents (0)

Package Sidebar

Install

npm i networked

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

3.03 kB

Total Files

6

Last publish

Collaborators

  • nathanielopdev