0.0.1-beta2 • Published 5 years ago
use-wait-order v0.0.1-beta2
use-wait-order
A react hook to wait for an order.
Install
npm i use-wait-order
Example
import createOrder from 'use-wait-order'
const sendMessage = createOrder(async txt => {
await client.send(txt)
})
function App(){
const isSending = sendMessage.useWait({delay: 300, duration: 600})
if(isSending){
return <Loading />
}
return (
<>
<Content />
<button onClick={() => sendMessage('hello')}>send!</button>
</>)
}
API
createOrder(orderer): order
Create a order function.
order(...args)
order.isWaiting
Returns whether the order is pending.
order.useWait(options)
delay
duration
License
MIT
0.0.1-beta2
5 years ago
0.0.1-beta1
5 years ago