New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

use-async-ops

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-async-ops

A library for asynchronous calls in React

latest
Source
npmnpm
Version
1.2.2
Version published
Weekly downloads
8
100%
Maintainers
1
Weekly downloads
 
Created
Source

use-async-ops

use-async-ops is a library for performing asynchronous operations in React applications utilizing hooks. This project is the successor to async-ops which was tightly coupled to Redux and Redux Sagas. With the help of hooks, this project was created to remove those dependencies and open up new possibilites along with simplify the code base. The actions dispatched by async-ops can be enabled with the use-async-ops-redux middleware.

Install

  npm install --save use-async-ops

useAsyncOp

The useAsyncOp hook provides the user with the asynchronous operation that has been previously registered as well as operation state values, including loading, error, and result.

import { useAsyncOp } from 'async-ops'

const Test = () => {
  const { call, loading, result, error } = useAsyncOp({ name: 'opName' })
  ...
}
Argument NameTypeDescription
namestringthe name of the operation
Return NameTypeDescription
callfunctionAn asynchronous method which wraps the operation
loadingbooleanboolean representing the loading state
resultanythe result returned by the operation
erroranythe error returned by the operation

useAsyncEffect

The useAsyncEffect hook is a convenience hook to perform the common pattern of using useEffect to load data when a component mounts. Instead of returning the call function, it will invoke it any time the hook arguments change and return the result and status fields just like useAsyncOp.

import { useAsyncEffect } from 'use-async-ops'

const Test = () => {
  const { loading, error, result } = useAsyncEffect({ name: 'opName' }, ['arg1', 'arg2'])
  ...
}
Argument NameTypeDescription
namestringthe name of the operation
... argsanythe rest of the arguments will be passed to the registered operation function
Return NameTypeDescription
loadingbooleanboolean representing the loading state
resultanythe result returned by the operation
erroranythe error returned by the operation

Keywords

react

FAQs

Package last updated on 10 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts